Page 1 of 1

650 - Bowl

Posted: Mon Jul 07, 2003 9:02 am
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:

Posted: Mon Jul 14, 2003 4:25 pm
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

Posted: Sun Jul 20, 2003 3:03 pm
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.

Posted: Tue Dec 12, 2006 5:02 pm
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!

Re: 650 - Bowl

Posted: Thu Jul 24, 2008 7:26 pm
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;
}

Re: 650 - Bowl

Posted: Thu Feb 05, 2009 11:52 am
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