Topic Portal (internal title 122)
Input Format
Enter the file first acts of a positive integer $ n $, said the two sides a total of how many steps the next move.
Then $ n $ line, enter the file two positive integers per line. The first two numbers $ I $ $ x rows, y $ represents $ I $ piece of a step in the $ x $ intersection of horizontal lines and vertical lines of $ Y $. If $ i $ is odd, this piece is Black, White otherwise.
Output Format
If no one wins, you need to export $ "Tie" $ (without the quotes). Otherwise, if $ A $ small wins, then the output $ "A" $ (without the quotes), if small wins $ B $ output $ "B" $. When someone wins, you also need to output a positive integer $ w $, $ w $ represents the first step after the game should end, separated by a space between letters and integers.
Sample
Sample input:
20
5 5
4 5
5 6
7 5
6 7
7 2
4 3
8 3
6 6
8 5
6 4
3 3
8 7
3 4
6 5
4 8
6 3
5 10
5 9
8 8
Sample output:
A 17
Data range and tips
For $ 100 \% $ data satisfies $ 0 \ leqslant n \ leqslant 225,1 \ leqslant x, y \ leqslant 15 $.
answer
Simulation, not a ......
Do not forget to pay attention to the function return value, $ exit (0) $ require cold storage, I know so much, and if someone has committed a stupid mistake, I can find another plus.
I feel my game is not a lot of details.
Time complexity: $ \ Theta (n) $.
Expectations score: $ 100 $ points.
实际得分:$100$分。
代码时刻
#include<bits/stdc++.h>
using namespace std;
int n;
int Map[20][20];
int ans;
bool judge(int x,int y)
{
int res1=1,res2=1,res3=1,res4=1;
for(int i=1;;i++)if(Map[x+i][y]!=Map[x][y]){res1+=i-1;break;}
for(int i=1;;i++)if(Map[x-i][y]!=Map[x][y]){res1+=i-1;break;}
for(int i=1;;i++)if(Map[x][y+i]!=Map[x][y]){res2+=i-1;break;}
for(int i=1;;i++)if(Map[x][y-i]!=Map[x][y]){res2+=i-1;break;}
for(int i=1;;i++)if(Map[x+i][y+i]!=Map[x][y]){res3+=i-1;break;}
for(int i=1;;i++)if(Map[x-i][y-i]!=Map[x][y]){res3+=i-1;break;}
for(int i=1;;i++)if(Map[x+i][y-i]!=Map[x][y]){res4+=i-1;break;}
for(int i=1;;i++)if(Map[x-i][y+i]!=Map[x][y]){res4+=i-1;break;}
if(res1>=5||res2>=5||res3>=5||res4>=5)return 1;
return 0;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
int x,y;
scanf("%d%d",&x,&y);
Map[x][y]=(i&1)+1;
if(!ans&&judge(x,y))ans=i;
}
if(!ans)puts("Tie");
else if(ans&1)printf("A %d",ans);
else printf("B %d",ans);
return 0;
}
rp++