650 - Bowl

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

Moderator: Board moderators

Post Reply
Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

650 - Bowl

Post by Observer »

I'm working on 650 Bowl and I'm getting WA!!!!!!! Why????!??!??!??!

Is the input well formed? I mean, does the names contains spaces or digits? Are there leading or trailing spaces??

And can someone give the some i/o??? Plz??? Thx in advance!!! :lol: :lol: :roll: :roll:
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Per
A great helper
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden

Post by Per »

Names can't contain spaces, but I see no reason why it shouldn't be possible for them to contain digits. (I just used scanf to read all input)

You could try this input:

Code: Select all

Chuck 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
Solly 0 0 0 0 0 0 0 0 0 0 0 8
Lothar 10 0 10 0 10 0
Brutus 5 1 2 0 6 0 9
McGillicuddy 0 0 1 0
Homer 0 10 0 0 0 0
Barney 0 0 0 0 0 0 0 0 0 0 1 0
Solly 0 0 0 0 0 0 0 0 0 0 0 8
Solly 0 0 0 0 0 0 0 0 0 0 0 8
Homer 0 10 0 0 0 0
Chuck 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
Solly 0 0 0 0 0 0 0 0 0 0 0 0
Solly 0 0 0 0 0 0 0 0 0 0 0
Solly 0 0 0 0 0 0 0 0 0 0
Solly 0 0 0 0 0 0 0 0 0 0 1
Solly 0 0 0 0 0 0 0 0 0 1
Output:

Code: Select all

Chuck        9/  9/  9/  9/  9/  9/  9/  9/  9/  9/9
              19  38  57  76  95 114 133 152 171 190

Solly        X   X   X   X   X   X   X   X   X   XX2
              30  60  90 120 150 180 210 240 270 292

Lothar       -/  -/  -/
              10  20

Brutus       54  8/  4/  1
               9  23  34

McGillicuddy X   X   9/
              29  49

Homer        X   -/  X   X   X
              20  40  70

Barney       X   X   X   X   X   X   X   X   X   X9/
              30  60  90 120 150 180 210 240 269 289

Solly        X   X   X   X   X   X   X   X   X   XX2
              30  60  90 120 150 180 210 240 270 292

Solly        X   X   X   X   X   X   X   X   X   XX2
              30  60  90 120 150 180 210 240 270 292

Homer        X   -/  X   X   X
              20  40  70

Chuck        9/  9/  9/  9/  9/  9/  9/  9/  9/  9/9
              19  38  57  76  95 114 133 152 171 190

Solly        X   X   X   X   X   X   X   X   X   XXX
              30  60  90 120 150 180 210 240 270 300

Solly        X   X   X   X   X   X   X   X   X   XX
              30  60  90 120 150 180 210 240 270

Solly        X   X   X   X   X   X   X   X   X   X
              30  60  90 120 150 180 210 240

Solly        X   X   X   X   X   X   X   X   X   X9
              30  60  90 120 150 180 210 240 269

Solly        X   X   X   X   X   X   X   X   X   9
              30  60  90 120 150 180 210 239
Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Post by Observer »

I've got ACC by handling the special case that the line contains the name only...

Note that in that sp. case, the name is NOT followed by any blanks.
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
pineapple
Learning poster
Posts: 57
Joined: Fri Nov 03, 2006 3:33 pm

Post by pineapple »

I didn't think about this special case.UVA's test cases is too terrible.
Without your great help I will always get PE.
Thank you very much!
Lyaxe
New poster
Posts: 3
Joined: Wed Feb 21, 2007 7:02 pm
Location: L

Re: 650 - Bowl

Post by Lyaxe »

tried all the possible input, still got WA, could someone test my code?
thanks

Code: Select all

#include<stdio.h>
#include<iostream>
#include<string>
#include<sstream>
#include<vector>

using namespace std;

int main()
{
    string s,t;
    stringstream ss;
    vector<int> A,B;
    vector<string> C;
    int x,y,z;
    int mark;
    
    mark = 0;
    while(cin >> s)
    {
        getline(cin,t);
        
        if(mark == 1)
            cout << endl;
        
        if(t.size() == 0)
        {
            A.clear();
            B.clear();
            C.clear();
            ss.clear();
            x = 0;
            y = 0;
            z = 0;
            while(s.size() < 12)
                s += " ";
            cout << s << endl;
        }
        else {
        x = 0; y = 0;
        while(x != string::npos)
        {
            y++;
            x = t.find(" ",x + 1);
        }
        
        A.clear();
        ss.clear();
        ss << t;
        for(x = 0;x < y;x++)
        {
            ss >> z;
            A.push_back(z);
        }
        
        C.clear();
        B.clear();
        for(x = 0;x < A.size();x++)
        {
            if(A[x] == 0)
            {
                if(C.size() == 0)
                {
                    C.push_back("X  ");
                    if(x + 2 < A.size())
                    {
                        if(A[x + 1] == 0)
                            B.push_back(10 + (10 - A[x + 1]) + (10 - A[x + 2]));
                        else
                            B.push_back(10 + (10 - A[x + 1]) + (A[x + 1] - A[x + 2]));
                    }
                    else
                        B.push_back(-3);
                }
                else if(C[C.size() - 1].size() == 3)
                {
                    C.push_back("X  ");
                    if(x + 2 < A.size())
                    {
                        if(A[x + 1] == 0)
                            B.push_back(10 + (10 - A[x + 1]) + (10 - A[x + 2]));
                        else
                            B.push_back(10 + (10 - A[x + 1]) + (A[x + 1] - A[x + 2]));
                    }
                    else
                        B.push_back(-3);
                }
                else if(C[C.size() - 1].size() == 1)
                {
                    C[C.size() - 1] += "/ ";
                    if(x + 1 < A.size())
                        B[B.size() - 1] = 10 + (10 - A[x + 1]);
                }
            }
            else if(A[x] == 10)
            {
                if(C.size() == 0)
                {
                    C.push_back("-");
                    B.push_back(-2);
                }
                else if(C[C.size() - 1].size() == 3)
                {
                    C.push_back("-");
                    B.push_back(-2);
                }
                else if(C[C.size() - 1].size() == 1)
                {
                    C[C.size() - 1] += "- ";
                    B[B.size() - 1] = 0;
                }
            }
            else
            {
                if(C.size() == 0)
                {
                    t = (10 - A[x]) + '0';
                    C.push_back(t);
                    B.push_back(-1);
                }
                else if(C[C.size() - 1].size() == 3)
                {
                    t = (10 - A[x]) + '0';
                    C.push_back(t);
                    B.push_back(-1);
                }
                else if(C[C.size() - 1].size() == 1)
                {
                    t = (A[x - 1] - A[x]) + '0';
                    t += " ";
                    C[C.size() - 1] += t;
                    B[B.size() - 1] = 10 - A[x];
                }
            }
        }
        
        if(C.size() == 12)
        {
            C[9][1] = C[10][0];
            C[9][2] = C[11][0];
            C.pop_back();
            C.pop_back();
        }
        
        if(C.size() == 11)
        {
            if(C[10].size() > 1)
            {
                C[9][1] = C[10][0];
                C[9][2] = C[10][1];
            }
            else
            {
                if(C[9][0] == 'X')
                    C[9][1] = C[10][0];
                else
                    C[9][2] = C[10][0];
            }
            C.pop_back();
        }
        
        while(B.size() > 10)
            B.pop_back();
        
        while(s.size() < 12)
            s += " ";
        
        cout << s;
        for(x = 0;x < C.size();x++)
        {
            z = C[x].find("0",0);
            if(z != string::npos)
                C[x][z] = '-';
            if(x == C.size() - 1)
            {
                while(C[x][C[x].size() - 1] == ' ')
                    C[x].erase(C[x].size() - 1,1);
            }
            cout << " " << C[x];
        }
        cout << endl;
        cout << "            ";
        z = 0;
        for(x = 0;x < B.size();x++)
        {
            if(B[x] < 0)
                z += 10;
            else
            {
                z += B[x];
                if(z / 100 == 0)
                    cout << " ";
                if(z / 10 == 0)
                    cout << " ";
                cout << " " << z;
            }
        }
        cout << endl;
        }
        mark = 1;
    }

    return 0;
}
Student of Computer Science at Universitas Katolik Parahyangan
coze
New poster
Posts: 26
Joined: Tue Nov 27, 2007 7:56 am
Location: Japan

Re: 650 - Bowl

Post by coze »

Hi, Lyaxe. Try the following cases.

Input:

Code: Select all

Homer 0
Homer
Homer 1 1
Homer 10 10 
Homer 10 0 9 0 8 7 6 5 4 3 2 1 0
Homer 5 5 5 0 5 0 5 5 5 5 
Homer 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 0 10 0
Homer 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 9 0 
Homer 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1 0 0
Homer 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1 0 0
Homer 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 0
Homer 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
Homer 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 8
Homer 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 0 0
Output:

Code: Select all

Homer        X


Homer


Homer        9-
               9

Homer        --
               0

Homer        -/  1/  21  41  61  81  X
              11  23  26  31  38  47

Homer        5-  5/  5/  5-  5-
               5  20  35  40  45

Homer        --  --  --  --  --  --  --  --  --  X-/
               0   0   0   0   0   0   0   0   0  20

Homer        --  --  --  --  --  --  --  --  --  1/
               0   0   0   0   0   0   0   0   0

Homer        --  --  --  --  --  --  --  --  --  9/X
               0   0   0   0   0   0   0   0   0  20

Homer        --  --  --  --  --  --  --  --  --  9/X
               0   0   0   0   0   0   0   0   0  20

Homer        --  --  --  --  --  --  --  --  --  X
               0   0   0   0   0   0   0   0   0

Homer        --  --  --  --  --  --  --  --  --  -
               0   0   0   0   0   0   0   0   0

Homer        --  --  --  --  --  --  --  --  --  2
               0   0   0   0   0   0   0   0   0

Homer        --  --  --  --  --  --  --  --  --  XX
               0   0   0   0   0   0   0   0   0
Post Reply

Return to “Volume 6 (600-699)”