SDUT 2523 OOXX

http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2523

思路 :就是先统计一下方阵中1多少2多少,确定一下下一步谁走,然后再从头开始找是0的位置,往上填下一步该谁走的棋,然后判断一下能不能构成三横三竖或者是对角线

#include <iostream>
#include <stdio.h>
#include <string.h> using namespace std ; int ch[][] = {{,,},{,,},{,,},{,,},{,,},{,,},{,,},{,,}} ;
int sh[] ;
int jude(int a,int b,int c)
{
return sh[a] && (sh[a] == sh[b]) && (sh[a] == sh[c]) ;
}
int main()
{
int n ;
cin>>n ;
for(int i = ; i < n ; i++)
{
for(int j = ; j < ; j++)
scanf("%d",&sh[j]) ;
int xh[] = {} ;
for(int j = ; j < ; j++)
xh[sh[j]]++ ;
int next ,flag = ;
if(xh[] == xh[])
next = ;
else next = ;
for(int j = ; j < &&flag ; j++)
{
if(sh[j] == )
{
sh[j] = next ;
for(int k = ; k < &&flag ; k++)
if(jude(ch[k][],ch[k][],ch[k][]))
flag = ;
sh[j] = ;
}
}
if(flag)
cout<<"NO"<<endl ;
else cout<<"YES"<<endl ;
}
return ;
}
上一篇:NumPy:数组计算


下一篇:AFNETWorking3.x实战教程