11060 - Beverages
Moderator: Board moderators
Re: 11060 - Beverages
Post your code
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Re: 11060 - Beverages
Code: Select all
below
Last edited by flashion on Wed Aug 06, 2014 3:59 pm, edited 1 time in total.
Re: 11060 - Beverages
Your terminating condition doesnt work. Maybe it is because of some spaces at the end of file. 
Change it to


Change it to
Code: Select all
while(cin >> n) {
name.clear();
Don't forget to remove your code after getting accepted.After each test case you must print a blank line.

A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Re: 11060 - Beverages
Last edited by flashion on Wed Aug 06, 2014 6:51 pm, edited 1 time in total.
Re: 11060 - Beverages
I repeat you again
It must beAfter each test case you must print a blank line.
Code: Select all
cout << "." << endl << endl;
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Re: 11060 - Beverages
Thank you, you're my hero.
Re: 11060 - Beverages
Ok, so I tested my code against all of the inputs in this topic and got correct outputs on all but I still get WA on the judge. Does anyone have any idea what's the problem?
Code: Select all
Removed after getting AC
Last edited by nbacool2 on Thu Aug 07, 2014 10:12 pm, edited 1 time in total.
Re: 11060 - Beverages
Don't forget to remove your code after getting accepted.After each test case you must print a blank line

A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Re: 11060 - Beverages
Thanks, got AC nowlighted wrote:Don't forget to remove your code after getting accepted.After each test case you must print a blank line


Re: 11060 - Beverages
Why am I getting a runtime error ?
//Accepted
//Accepted
Last edited by sreka11 on Wed Sep 10, 2014 8:07 pm, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11060 - Beverages
It looks like you figured it out.
Check input and AC output for thousands of problems on uDebug!
Re: 11060 - Beverages
Thanks anyway
Re: 11060 - Beverages
I can't seem to understand why I"m getting WA, I tried the cases I found here but my code passes them, here's my code http://ideone.com/YVyvZl
Re: 11060 - Beverages
I sent you PM
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
11060 Beverages Why Time Limit ???? Help Anyone Please...
Code: Select all
#include<cstdio>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<iostream>
#define MAX 300
using namespace std;
int mat[MAX][MAX],indegree[MAX],cnt,color[MAX];
string a,X,Y,stor;
map<string,int>mymap;
map<int,string>my;
void TOP(int N)
{
queue<int>Q;
int t=0;
while(cnt!=N)
{
for(int i=1; i<=N; i++)
{
if(indegree[i]==0&&color[i]==0)
{
if(t==0)
stor +=my[i];
else
stor += " "+my[i];
//hold[k++] = i;
Q.push(i);
cnt++;
color[i] = 1;
//cout<<cnt<<endl;
t++;
}
if(cnt==N)
break;
}
if(cnt==N)
break;
//cout<<stor<<endl;
while(!Q.empty())
{
int frt = Q.front();
Q.pop();
for(int j=1; j<=N; j++)
{
if(mat[frt][j]==1)
{
indegree[j] = indegree[j] - 1;
if(indegree[j]==0&&color[j]==0)
{
Q.push(j);
color[j] = 1;
stor += " "+my[j];
cnt++;
}
}
if(cnt==N)
break;
}
if(cnt==N)
break;
}
if(cnt==N)
break;
}
}
int main()
{
int N,M,top,cse=0;
while(scanf("%d",&N)==1)
{
memset(mat,0,sizeof(mat));
memset(indegree,0,sizeof(indegree));
memset(color,0,sizeof(color));
cse++;
stor = "\0";
//cout<<stor<<endl;
cnt=0;
top = 1;
for(int i=1; i<=N; i++)
{
cin>>a;
if(!mymap[a])
{
mymap[a] = top;
my[top] = a;
//cout<<"X "<<my[top]<<" "<<top<<endl;
top++;
}
}
// for(int i=1; i<=N; i++)
// indegree[i] = 0;
scanf("%d",&M);
for(int i=1; i<=M; i++)
{
cin>>X>>Y;
mat[mymap[X]][mymap[Y]] = 1;
indegree[mymap[Y]] = indegree[mymap[Y]] + 1;
}
// for(int i=1; i<=N; i++){
// printf("%d ",indegree[i]);
// cout<<my[i]<<endl;
// }
TOP(N);
cout<<"Case #"<<cse<<": Dilbert should drink beverages in this order: "<<stor<<"."<<"\n"<<endl;
mymap.clear();
my.clear();
}
return 0;
}
Last edited by brianfry713 on Thu Oct 30, 2014 9:09 pm, edited 1 time in total.
Reason: Added code blocks
Reason: Added code blocks