poj2260

来源:互联网 发布:狗粮 饼干 淘宝 编辑:程序博客网 时间:2024/06/05 13:27

1 题目

水题

2 分析

3

#include <iostream>#include <string.h>#include <algorithm>#include <stdio.h>using namespace std;int mat[110][110];int row[110];int col[110];int main(){    int n;    while(~scanf("%d",&n)&&n!=0){        ///ini+function1        memset(row,0,sizeof(row));        memset(col,0,sizeof(col));        for(int i=1;i<=n;i++){            for(int j=1;j<=n;j++){                scanf("%d",&mat[i][j]);                if(mat[i][j]){                    row[i]++;                    col[j]++;                }            }        }        ///function2        int bj=0;        int temp_x=0,temp_y=0;        for(int i=1;i<=n;i++){            if(row[i]&1){                bj++;                temp_x=i;                //cout<<"row_bj: "<<bj<<" "<<temp_x<<endl;            }            if(col[i]&1){                bj++;                temp_y=i;                //cout<<"col_bj: "<<bj<<" "<<temp_y<<endl;            }        }        if(bj==0){            cout<<"OK"<<endl;            continue;        }        else if(bj==2&&temp_x!=0&&temp_y!=0){            printf("Change bit (%d,%d)\n",temp_x,temp_y);        }        else{            cout<<"Corrupt"<<endl;        }    }    return 0;}

0 0