Thursday, June 9, 2016

uva 541 - Error Correction -solution

Unknown
#include<cstdio>
#include<string.h>
using namespace std;

int main()
{
    int n,bit[100][100];
   
    while (scanf("%d",&n)==1)
    {
        if (n==0) return 0;
        int a,r,c,cntr,cntc;
        int row[n],col[n];
        memset(row,0,sizeof(row));
        memset(col,0,sizeof(col));
        for (int i=0;i<n;i++)
        {
            for (int j=0;j<n;j++)
            {
                scanf("%d",&a);
                bit[i][j]=a;
                row[i]+=a;
                col[j]+=a;
            }
        }
        cntr=0;
        cntc=0;
        for (int i=0;i<n;i++)
        {
            if (row[i]%2)
            {
                cntr++;
                r=i;
            }
            if (col[i]%2)
            {
                cntc++;
                c=i;
            }
        }
       
        if (cntr==0 && cntc==0) printf("OK\n");
        else if (cntr==1 && cntc==1) printf("Change bit (%d,%d)\n",r+1,c+1);
        else printf("Corrupt\n");
       
    }
    return 0;
   
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,