首页 > 代码库 > XTU_1173 Five Tiger

XTU_1173 Five Tiger

 http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1173

纯模拟,按步骤一个个来 判断就行。

#include<cstdio>
#include<cstring>
int main()
{
    //freopen("a.txt","r",stdin);
    char map[10][10];
    int t,i,j,s1,s2;
    scanf("%d",&t);
    getchar();
    while(t--)
    {
        getchar();
        s1=s2=0;
        for(i=0;i<5;i++)
        {
            for(j=0;j<5;j++)
            scanf("%c",&map[i][j]);
            getchar();
        }
        //for(i=0;i<5;i++)
           // printf("%s\n",map[i]);
        if(map[0][0]=='x'&&map[0][4]=='x'&&map[4][0]=='x'&&map[4][4]=='x'&&map[2][2]=='x')
            s1+=10;
        if(map[0][0]=='o'&&map[0][4]=='o'&&map[4][0]=='o'&&map[4][4]=='o'&&map[2][2]=='o')
            s2+=10;
        //printf("%d %d\n",s1,s2);
        for(i=0;i<3;i++)
        {
            for(j=0;j<3;j++)
            {
            if(map[i][j]=='x'&&map[i+2][j]=='x'&&map[i][j+2]=='x'&&map[i+2][j+2]=='x'&&map[i+1][j+1]=='x')
                s1+=5;
            if(map[i][j]=='o'&&map[i+2][j]=='o'&&map[i][j+2]=='o'&&map[i+2][j+2]=='o'&&map[i+1][j+1]=='o')
                s2+=5;
            }
        }
        for(i=0;i<5;i++)
        {
            if(map[0][i]=='x'&&map[1][i]=='x'&&map[2][i]=='x'&&map[3][i]=='x'&&map[4][i]=='x')
                s1+=5;
            if(map[0][i]=='o'&&map[1][i]=='o'&&map[2][i]=='o'&&map[3][i]=='o'&&map[4][i]=='o')
                s2+=5;
            if(map[i][0]=='x'&&map[i][1]=='x'&&map[i][2]=='x'&&map[i][3]=='x'&&map[i][4]=='x')
                s1+=5;
            if(map[i][0]=='o'&&map[i][1]=='o'&&map[i][2]=='o'&&map[i][3]=='o'&&map[i][4]=='o')
                s2+=5;
        }
        if(map[0][0]=='x'&&map[1][1]=='x'&&map[2][2]=='x'&&map[3][3]=='x'&&map[4][4]=='x')
            s1+=5;
        if(map[0][0]=='o'&&map[1][1]=='o'&&map[2][2]=='o'&&map[3][3]=='o'&&map[4][4]=='o')
            s2+=5;
        if(map[4][0]=='x'&&map[3][1]=='x'&&map[2][2]=='x'&&map[1][3]=='x'&&map[0][4]=='x')
            s1+=5;
        if(map[4][0]=='o'&&map[3][1]=='o'&&map[2][2]=='o'&&map[1][3]=='o'&&map[0][4]=='o')
            s2+=5;
        if(map[3][0]=='x'&&map[2][1]=='x'&&map[1][2]=='x'&&map[0][3]=='x')
            s1+=4;
        if(map[3][0]=='o'&&map[2][1]=='o'&&map[1][2]=='o'&&map[0][3]=='o')
            s2+=4;
        if(map[1][0]=='x'&&map[2][1]=='x'&&map[3][2]=='x'&&map[4][3]=='x')
            s1+=4;
        if(map[1][0]=='o'&&map[2][1]=='o'&&map[3][2]=='o'&&map[4][3]=='o')
            s2+=4;
        if(map[4][1]=='x'&&map[3][2]=='x'&&map[2][3]=='x'&&map[1][4]=='x')
            s1+=4;
        if(map[4][1]=='o'&&map[3][2]=='o'&&map[2][3]=='o'&&map[1][4]=='o')
            s2+=4;
        if(map[0][1]=='x'&&map[1][2]=='x'&&map[2][3]=='x'&&map[3][4]=='x')
            s1+=4;
        if(map[0][1]=='o'&&map[1][2]=='o'&&map[2][3]=='o'&&map[3][4]=='o')
            s2+=4;
        if(map[0][2]=='x'&&map[1][1]=='x'&&map[2][0]=='x')
            s1+=3;
        if(map[0][2]=='o'&&map[1][1]=='o'&&map[2][0]=='o')
            s2+=3;
        if(map[2][0]=='x'&&map[3][1]=='x'&&map[4][2]=='x')
            s1+=3;
        if(map[2][0]=='o'&&map[3][1]=='o'&&map[4][2]=='o')
            s2+=3;
        if(map[2][4]=='x'&&map[3][3]=='x'&&map[4][2]=='x')
            s1+=3;
        if(map[2][4]=='o'&&map[3][3]=='o'&&map[4][2]=='o')
            s2+=3;
        if(map[0][2]=='x'&&map[1][3]=='x'&&map[2][4]=='x')
            s1+=3;
        if(map[0][2]=='o'&&map[1][3]=='o'&&map[2][4]=='o')
            s2+=3;
        for(i=0;i<4;i++)
        {
            for(j=0;j<4;j++)
            {
                if(map[i][j]=='x'&&map[i][j+1]=='x'&&map[i+1][j]=='x'&&map[i+1][j+1]=='x')
                    s1+=1;
                if(map[i][j]=='o'&&map[i][j+1]=='o'&&map[i+1][j]=='o'&&map[i+1][j+1]=='o')
                    s2+=1;
            }
        }
        printf("%d %d\n",s1,s2);
    }
    return 0;
}


 

XTU_1173 Five Tiger