跳到正文

题解

题解:P17093 [ICPC 2017 Qingdao R] Chenchen, Tangtang and ZengZeng

ShiYuXuan1234约 2 分钟
原文
文章信息与版本

文章信息

发布
2026年7月12日
收录
2026年7月14日
更新
2026年11月15日
篇幅
约 2 分钟
获赞
1
题目
P17093

版本

  1. v1当前
前言

或许有更好的、不那么诡异的方法,但最直接的就是这个方法了。

思路

硬判断。

把所有三连的可能性都判断一次即可。

AC 代码
C++
#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 记录。

原文