题解:P17093 [ICPC 2017 Qingdao R] Chenchen, Tangtang and ZengZeng
ShiYuXuan1234 · · 题解
::::info[前言] 或许有更好的、不那么诡异的方法,但最直接的就是这个方法了。 :::: ::::info[思路]{open} 硬判断。
| 把所有三连的可能性都判断一次即可。 |
|---|
| ::::success[AC 代码] |
| ```cpp |
| #include <bits/stdc++.h> |
| using namespace std; |
| #define int long long |
| char c[10][10]; |
| char pd(int x1,int y1,int x2,int y2,int x3,int y3){ |
| if(c[x1][y1]==c[x2][y2]&&c[x1][y1]==c[x3][y3]&&c[x1][y1]!='.'){//三颗棋子相连 |
| return c[x1][y1]; |
| }else{ |
| return '#'; |
| } |
| } |
| signed main(){ |
| int T; |
| cin>>T; |
| while(T--){ |
| for(int i=1;i<=3;i++){ |
| for(int j=1;j<=3;j++){ |
| cin>>c[i][j]; |
| } |
| } |
| //各种可能 |
| if(pd(1,1,1,2,1,3)!='#'){ |
| cout<<pd(1,1,1,2,1,3)<<endl; |
| continue; |
| } |
| if(pd(2,1,2,2,2,3)!='#'){ |
| cout<<pd(2,1,2,2,2,3)<<endl; |
| continue; |
| } |
| if(pd(3,1,3,2,3,3)!='#'){ |
| cout<<pd(3,1,3,2,3,3)<<endl; |
| continue; |
| } |
| if(pd(1,1,2,1,3,1)!='#'){ |
| cout<<pd(1,1,2,1,3,1)<<endl; |
| continue; |
| } |
| if(pd(1,2,2,2,3,2)!='#'){ |
| cout<<pd(1,2,2,2,3,2)<<endl; |
| continue; |
| } |
| if(pd(1,3,2,3,3,3)!='#'){ |
| cout<<pd(1,3,2,3,3,3)<<endl; |
| continue; |
| } |
| if(pd(1,1,2,2,3,3)!='#'){ |
| cout<<pd(1,1,2,2,3,3)<<endl; |
| continue; |
| } |
| if(pd(1,3,2,2,3,1)!='#'){ |
| cout<<pd(1,3,2,2,3,1)<<endl; |
| continue; |
| } |
| cout<<"ongoing\n"; |
| } |
| return 0; |
| } |
| ``` |
| AC 记录。 |
| :::: |