这题数据规模很小,考的是枚举。
枚举每个点是否应该施法就可以了。
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<string>
#include<map>
#define int long long
using namespace std;
const int mod=1e9+7;
const int maxn=1e6+10;</map></string></set></cmath></cstring></algorithm></cstdio></iostream>
int t;
int mp[5][5];
int qp[5][5];
int dx[5]={-1,0,1,0,0};
int dy[5]={0,1,0,-1,0};
int f(int x){
if(x)
return 0;
return 1;
}
int check(int x){
for(int i=1;i<=4;i++){
for(int j=1;j<=4;j++){
qp[i][j]=mp[i][j];
}
}
for(int i=1;i<=4;i++){
for(int j=1;j<=4;j++){
int y=x&1;
x=x>>1;
if(y){
for(int k=0;k<5;k++){
int tx=i+dx[k],ty=j+dy[k];
if(tx>=1&&ty>=1&&tx<=4&&ty<=4){
qp[tx][ty]=f(qp[tx][ty]);
}
}
}
}
}
int ok=1;
for(int i=1;i<=4;i++){
for(int j=1;j<=4;j++){
if(qp[i][j]){
ok=0;
break;
}
}
}
if(ok)
return 1;
return 0;
}
signed main(){
for(int i=1;i<=4;i++){
char str[10];
cin>>str;
for(int j=1;j<=4;j++)
mp[i][j]=str[j-1]-'0';
}
int up=1<<16;
int ok=0;
for(int i=0;i<up;i++){
if(check(i)){
ok=1;
break;
}
}
if(ok){
cout<<"YES"<<endl;
}
else{
cout<<"NO"<<endl;
}
return 0;
}