Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<cstdio>
- #include<cstdlib>
- #define N 52
- using namespace std;
- typedef struct _Spot{
- bool chess[N][N];
- }Spot;
- Spot spot[8*N];
- bool game[N][N];
- int n;
- int Init()
- {
- for(int i = 0;i < n;++i)
- for(int j = 0;j < n;j++)
- {
- game[i][j] = false;
- }
- }
- int Add_spot(int num)
- {
- for(int i = 0;i < n;i++)
- for(int j = 0;j < n;j++)
- spot[num].chess[i][j] = game[i][j];
- num++;
- for(int i = 0;i < n;i++)
- for(int j = 0;j < n;j++)
- spot[num].chess[i][j] = game[n-j][i];
- num++;
- for(int i = 0;i < n;i++)
- for(int j = 0;j < n;j++)
- spot[num].chess[i][j] = game[n-i][n-j];
- num++;
- for(int i = 0;i < n;i++)
- for(int j = 0;j < n;j++)
- spot[num].chess[i][j] = game[j][n-i];
- }
- bool judge(int num)
- {
- for(int i = 0;i < n;i++)
- for(int j = 0;j < n;j++)
- if(game[i][j] != spot[num].chess[i][j])
- return false;
- return true;
- }
- int main()
- {
- while(~scanf("%d",&n) && n)
- {
- Init();
- int result = 0;
- int cc = 0;
- for(int i = 1;i <= 2*n;++i)
- {
- int xx,yy;
- char oper;
- scanf("%d %d %c",&xx,&yy,&oper);
- game[xx-1][yy-1] = '+' == oper ? true : false;
- if(!result)
- {
- bool check = false;
- for(int p = 0;p < cc;p++)
- if(judge(p))
- {
- check = true;
- break;
- }
- if(check)
- result = i%2==0 ? -i:i;
- Add_spot(cc);
- cc+=4;
- }
- }
- if(result > 0)
- printf("Player 2 wins on move %d\n",result);
- else if(result < 0)
- printf("Player 1 wins on move %d\n",-result);
- else
- printf("Draw\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement