#include <bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin>>n >>m;
int X = 0;
int Y = 0;
for(int i = 0; i < n;i++){
string W;
cin>>W;
for(int j = 0; j < m;j++){
if(W[j] == 'O'){
if(i + j % 2 == 0){
X++;
}else{
Y++;
}
}
}
}
int q = 0;
int w = 0;
for(int i = 0; i < n;i++){
string W;
cin>>W;
for(int j = 0; j < m;j++){
if(W[j] == 'O'){
if(i + j % 2 == 0){
q++;
}else{
w++;
}
}
}
}
if(q != X && w != Y){
cout<<"0";
}else{
cout<<"1";
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #include <bits/stdc++.h> using namespace std; int main(){ int n,m; cin>>n >>m; int X = 0; int Y = 0; for(int i = 0; i < n;i++){ string W; cin>>W; for(int j = 0; j < m;j++){ if(W[j] == 'O'){ if(i + j % 2 == 0){ X++; }else{ Y++; } } } } int q = 0; int w = 0; for(int i = 0; i < n;i++){ string W; cin>>W; for(int j = 0; j < m;j++){ if(W[j] == 'O'){ if(i + j % 2 == 0){ q++; }else{ w++; } } } } if(q != X && w != Y){ cout<<"0"; }else{ cout<<"1"; } } |
English