#3054:


alusunkiyu (艾爾)

學校 : 國立大里高級中學
編號 : 6261
來源 : [114.41.28.161]
最後登入時間 :
2011-05-21 15:50:36
b216. 1. 棒球九宮格 -- 97學年度全國資訊學科能力競賽 | From: [114.41.22.200] | 發表日期 : 2009-12-20 12:27

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    string s;

    while(cin >> s)
    {
        int ball[18];
        for(int i=0; i<18; i++)
            cin >> ball[i];

        int check[9];
        for(int i=0; i<9; i++)
            check[i]=0;

        int point=0;
        for(int j=0; j<9; j++)
        {
            if(ball[j*2]>0 && ball[j*2]<10)
            {
                if(ball[j*2+1]>0 && ball[j*2+1]<10 && check[6]!=7)
                {
                    check[6]=7;
                    point+=8;
                }
                else if(ball[j*2+1]>10 && ball[j*2+1]<20 && check[3]!=4)
                {
                    check[3]=4;
                    point+=5;
                }
                else if(ball[j*2+1]>20 && ball[j*2+1]<30 && check[0]!=1)
                {
                    check[0]=1;
                    point+=8;
                }
            }
            else if(ball[j*2]>10 && ball[j*2]<20)
            {
                if(ball[j*2+1]>0 && ball[j*2+1]<10 && check[7]!=8)
                {
                    check[7]=8;
                    point+=5;
                }
                else if(ball[j*2+1]>10 && ball[j*2+1]<20 && check[4]!=5)
                {
                    check[4]=5;
                    point+=2;
                }
                else if(ball[j*2+1]>20 && ball[j*2+1]<30 && check[1]!=2)
                {
                    check[1]=2;
                    point+=5;
                }
            }
            else if(ball[j*2]>20 && ball[j*2]<30)
            {
                if(ball[j*2+1]>0 && ball[j*2+1]<10 && check[8]!=9)
                {
                    check[8]=9;
                    point+=8;
                }
                else if(ball[j*2+1]>10 && ball[j*2+1]<20 && check[5]!=6)
                {
                    check[5]=6;
                    point+=5;
                }
                else if(ball[j*2+1]>20 && ball[j*2+1]<30 && check[2]!=3)
                {
                    check[2]=3;
                    point+=8;
                }
            }
        }

        int count=0;
        for(int k=0 ;k<3; k++)
            if(check[k*3]+check[k*3+1]+check[k*3+2]==9*k+6)
                count++;

        for(int k=0 ;k<3; k++)
            if(check[k]+check[k+3]+check[k+6]==3*k+12)
                count++;

        //cout << "輸出範例" << s[8] << ":" << endl;
        cout << count << " " << point << endl << endl;
    }

    //system("PAUSE");
    return EXIT_SUCCESS;
}

 

我用範例的輸入都對呀= ="

可是一送上來答案就不同了

 
ZeroJudge Forum