A. Appleman and Easy Task
题意:给你一个n*n的图案,每一个点是 o 或 * ,问是否每个位置 都有偶数个相邻的 o n<=100
题解:直接模拟即可
代码:
1 #include<cstdio> 2 #include<cstdlib> 3 #include<cmath> 4 #include<cstring> 5 #include<algorithm> 6 #include<iostream> 7 #include<vector> 8 #include<map> 9 #include<set> 10 #include<queue> 11 #define inf 1000000000 12 #define maxn 500+100 13 #define maxm 500+100 14 #define eps 1e-10 15 #define ll long long 16 #define pa pair<int,int> 17 using namespace std; 18 inline int read() 19 { 20 int x=0,f=1;char ch=getchar(); 21 while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} 22 while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();} 23 return x*f; 24 } 25 int n; 26 char a[maxn][maxn]; 27 const int dx[4]={0,1,-1,0}; 28 const int dy[4]={1,0,0,-1}; 29 bool solve() 30 { 31 n=read(); 32 for(int i=1;i<=n;i++) 33 for (int j=1;j<=n;j++) 34 { 35 char ch=' '; 36 while(ch!='o'&&ch!='x')ch=getchar(); 37 a[i][j]=ch; 38 } 39 for(int i=1;i<=n;i++) 40 for (int j=1;j<=n;j++) 41 { 42 int cnt=0; 43 for (int k=0;k<4;k++) 44 { 45 int x=i+dx[k],y=j+dy[k]; 46 if(x>0&&x<=n&&y<=n&&y>0) 47 if(a[x][y]=='o')cnt++; 48 } 49 if(cnt&1)return 0; 50 } 51 return 1; 52 } 53 int main() 54 { 55 if(solve())puts("YES");else puts("NO"); 56 return 0; 57 }