11060 - Beverages

All about problems in Volume 110. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 11060 - Beverages

Post by lighted » Wed Aug 06, 2014 2:57 am

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

flashion
New poster
Posts: 17
Joined: Thu Jul 24, 2014 10:29 pm

Re: 11060 - Beverages

Post by flashion » Wed Aug 06, 2014 10:32 am

Code: Select all

below
Last edited by flashion on Wed Aug 06, 2014 3:59 pm, edited 1 time in total.

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 11060 - Beverages

Post by lighted » Wed Aug 06, 2014 3:39 pm

Your terminating condition doesnt work. Maybe it is because of some spaces at the end of file. :)

Change it to

Code: Select all

while(cin >> n) {
  name.clear();
After each test case you must print a blank line.
Don't forget to remove your code after getting accepted. 8)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

flashion
New poster
Posts: 17
Joined: Thu Jul 24, 2014 10:29 pm

Re: 11060 - Beverages

Post by flashion » Wed Aug 06, 2014 3:59 pm

Thanks, but still WA :(

Code: Select all

AC
Last edited by flashion on Wed Aug 06, 2014 6:51 pm, edited 1 time in total.

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 11060 - Beverages

Post by lighted » Wed Aug 06, 2014 4:29 pm

I repeat you again
After each test case you must print a blank line.
It must be

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

flashion
New poster
Posts: 17
Joined: Thu Jul 24, 2014 10:29 pm

Re: 11060 - Beverages

Post by flashion » Wed Aug 06, 2014 6:51 pm

Thank you, you're my hero.

nbacool2
New poster
Posts: 24
Joined: Fri Jul 25, 2014 4:31 pm

Re: 11060 - Beverages

Post by nbacool2 » Thu Aug 07, 2014 8:31 pm

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.

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 11060 - Beverages

Post by lighted » Thu Aug 07, 2014 9:56 pm

After each test case you must print a blank line
Don't forget to remove your code after getting accepted. 8)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

nbacool2
New poster
Posts: 24
Joined: Fri Jul 25, 2014 4:31 pm

Re: 11060 - Beverages

Post by nbacool2 » Thu Aug 07, 2014 10:11 pm

lighted wrote:
After each test case you must print a blank line
Don't forget to remove your code after getting accepted. 8)
Thanks, got AC now :) ! That's one of the things I hate about UVa - the fancy output and strict rules. I waste a lot of time wondering what's wrong with my code when it's the output formatting :x

sreka11
New poster
Posts: 15
Joined: Fri Aug 15, 2014 8:06 pm

Re: 11060 - Beverages

Post by sreka11 » Wed Sep 10, 2014 3:43 pm

Why am I getting a runtime error ?

//Accepted
Last edited by sreka11 on Wed Sep 10, 2014 8:07 pm, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11060 - Beverages

Post by brianfry713 » Wed Sep 10, 2014 7:32 pm

It looks like you figured it out.
Check input and AC output for thousands of problems on uDebug!

sreka11
New poster
Posts: 15
Joined: Fri Aug 15, 2014 8:06 pm

Re: 11060 - Beverages

Post by sreka11 » Tue Sep 23, 2014 2:44 pm

Thanks anyway

z_shadow
New poster
Posts: 1
Joined: Sat Oct 11, 2014 12:17 pm

Re: 11060 - Beverages

Post by z_shadow » Sat Oct 11, 2014 12:24 pm

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

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 11060 - Beverages

Post by lighted » Sat Oct 11, 2014 3:12 pm

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

Rafiq123
New poster
Posts: 3
Joined: Fri Jun 27, 2014 6:31 pm

11060 Beverages Why Time Limit ???? Help Anyone Please...

Post by Rafiq123 » Thu Oct 30, 2014 2:18 pm

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

Post Reply

Return to “Volume 110 (11000-11099)”