#include <iostream> using namespace std; int main(){ int n,rc[101][101]; int i,j,tempsr[101],tempsc[101],x[101],y[101]; while(cin>>n,n!=0){ for (i = 0;i < n;i++) for (j = 0;j < n;j++) cin>>rc[i][j]; //若行的奇数和的个数不等于列的奇数和的个数则Corrupt //若均为0 则OK //若相等 则可作变换,可以一一配对得到交点就是变换点 memset(tempsc,0,sizeof(tempsc)); memset(tempsr,0,sizeof(tempsr)); for (i = 0;i < n;i++) for (j = 0;j < n;j++){ tempsr[i]+=rc[i][j]; tempsc[i]+=rc[j][i]; } int a = 0,b = 0; for (i = 0;i < n;i++) { if (tempsr[i] % 2 == 1) x[a++] = i+1; if (tempsc[i] % 2 == 1 ) y[b++] = i+1; } if (a != b) cout<<"Corrupt"<<endl; if (!a && !b) cout<<"OK"<<endl; if (a == b) for (i = 0;i < a;i++) { cout<<"Change bit ("<<x[i]<<","<<y[i]<<")"<<endl; } } return 0; }
POJ 2260 Error Correction 模拟题
最新推荐文章于 2021-02-28 23:11:31 发布