PARIGAME - VOI 2011 Trò chơi chẵn lẻ
Tác giả: flashmt
Ngôn ngữ: C++
#include<iostream>
#include<algorithm>
#define fr(a,b,c) for (a=b;a<=c;a++)
using namespace std;
int test,n,i,j,x,row[555][555],col[555][555],f[555][555];
int main()
{
cin >> test;
while (test--)
{
cin >> n;
fr(i,1,n)
fr(j,1,n)
{
scanf("%d",&x);
x%=2;
row[i][j]=(row[i][j-1]+x)%2;
col[j][i]=(col[j][i-1]+x)%2;
}
fr(i,1,n)
fr(j,1,n)
{
f[i][j]=0;
if (!f[i-1][j] && !row[i][j]) f[i][j]=1;
if (!f[i][j-1] && !col[j][i]) f[i][j]=1;
}
if (f[n][n]) cout << "YES" << endl; else cout << "NO" << endl;
}
}