0%

[題解]錯誤更正

a159/ 錯誤更正

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
42
43
#include <bits/stdc++.h>
#define N 105
#define mod 1000000007
#define FOR(i,n) for(int i=0;i<n;i++)
#define ios ios::sync_with_stdio(0)
using namespace std;


signed main(){
ios;
int n;
while(cin>>n && n!=0){
int row_sum[N],col_sum[N],arr[N][N];
memset(row_sum,0,sizeof(row_sum));
memset(col_sum,0,sizeof(col_sum));
memset(arr,0,sizeof(arr));

for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cin>>arr[i][j];
row_sum[i]+=arr[i][j];
col_sum[j]+=arr[i][j];
}
}
int rcnt = 0,ccnt = 0;
int rind = 0,cind = 0;

for(int i=1;i<=n;i++){
if(row_sum[i]%2){
rcnt += 1;
rind = i;
}
if(col_sum[i]%2){
ccnt += 1;
cind = i;
}
}
if(rcnt==0 && ccnt==0)cout<<"OK"<<endl;
else if(rcnt==1 && ccnt==1)cout<<"Change bit ("<<rind<<","<<cind<<")"<<endl;
else cout<<"Corrupt"<<endl;
}
}