20
  • 板块P1838 三子棋I
  • 楼主Ghy_boy
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/12/17 19:11
  • 上次更新2023/12/17 21:31:19
查看原帖
20
1086459
Ghy_boy楼主2023/12/17 19:11
#include<bits/stdc++.h>
using namespace std;
char s[10];
bool a1[9][9];
int a[10];
int funga(char s[]){
	for(int i=1;i<=9;i++){
		a[i]=s[i-1]-'0';
	}
	for(int i=1;i<=9;i++){
		if(a[i]<=3){
			if(i%2!=0) a1[i][1]=true;
			else a1[i][1]=false;
		}
		if(a[i]<=6&&a[i]>3){
			if(i%2!=0) a1[i][1]=true;
			else a1[i][1]=false;
		}
		if(a[i]<=9&&a[i]>6){
            if(i%2!=0) a1[i][1]=true;
			else a1[i][1]=false;
		}
	}
	for(int i=1;i<=9;i++){
		for(int j=1;i<=3;i++){
			if(a1[i][1]==a1[i][2]&&a1[i][1]==a1[i][3] || a1[1][j]==a1[2][j]&&a1[1][j]==a1[3][j] || a1[i][j]==a1[i+1][j+1]&&a1[i][j]==a1[i+2][j+2]){
				if(a1[i][1]==true&&a1[i][j]==true) return 2e9;
				else return -2e9;
			}

		}
	}

}
int main()
{
	cin>>s;
	if(funga(s) == 2e9) cout<<"xiaoa wins."<<endl;
	else if(funga(s) == -2e9) cout<<"uim wins."<<endl;
	else{
		cout<<"drew."<<endl;
	}
return 0;
}
2023/12/17 19:11
加载中...