Error Correction
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 6014   Accepted: 3886

Description

A boolean matrix has the parity property when each row and each column has an even sum, i.e. contains an even number of bits which are set. Here's a 4 x 4 matrix which has the parity property:

1 0 1 0

0 0 0 0

1 1 1 1

0 1 0 1

The sums of the rows are 2, 0, 4 and 2. The sums of the columns are 2, 2, 2 and 2. 

Your job is to write a program that reads in a matrix and checks if it has the parity property. If not, your program should check if the parity property can be established by changing only one bit. If this is not possible either, the matrix should be classified
as corrupt. 


Input

The input will contain one or more test cases. The first line of each test case contains one integer n (n<100), representing the size of the matrix. On the next n lines, there will be n integers per line. No other integers than 0 and 1 will occur in the matrix.
Input will be terminated by a value of 0 for n.

Output

For each matrix in the input file, print one line. If the matrix already has the parity property, print "OK". If the parity property can be established by changing one bit, print "Change bit (i,j)" where i is the row and j the column of the bit to be changed.
Otherwise, print "Corrupt".

Sample Input

4
1 0 1 0
0 0 0 0
1 1 1 1
0 1 0 1
4
1 0 1 0
0 0 1 0
1 1 1 1
0 1 0 1
4
1 0 1 0
0 1 1 0
1 1 1 1
0 1 0 1
0

Sample Output

OK
Change bit (2,3)
Corrupt

Source

你  离  开  了  ,  我  的  世  界  里  只  剩  下  雨  。  。  。

#include <iostream>
using namespace std;
int main()
{
int a[105][105],b[105],c[105],i,j,n;
while(cin >> n,n)
{
for(i = 0; i<n; i++)
for(j = 0; j<n; j++)
cin >> a[i][j];
for(i = 0; i<n; i++)
{
b[i] = 0;
for(j = 0; j<n; j++)
b[i]+=a[i][j];
}
for(i = 0; i<n; i++)
{
c[i] = 0;
for(j = 0; j<n; j++)
c[i]+=a[j][i];
}
int sum1=0,sum2 = 0,flag1,flag2;
for(i = 0; i<n; i++)
if(b[i]%2)
sum1++,flag1 = i;
for(i = 0; i<n; i++)
if(c[i]%2) sum2++,flag2 = i;
if(sum1 > 1 || sum2>1)cout << "Corrupt" << endl;
else if(!sum1 && !sum2)cout << "OK" << endl;
else cout << "Change bit (" << flag1+1 << "," << flag2+1 << ")" << endl;
}
return 0;
}

POJ 2260:Error Correction的更多相关文章

  1. POJ 2260 Error Correction 模拟 贪心 简单题

    Error Correction Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6825   Accepted: 4289 ...

  2. FEC(Forward Error Correction)前向纠错 UDP\RTP 中使用用于改善无线等网络丢包等问题--转

    FEC(Forward Error Correction)前向纠错 UDP\RTP 中使用用于改善无线等网络丢包等问题 算法暂不介绍. 思路:FEC ENCODE 增加冗余包,当无线等网络丢包之后,接 ...

  3. zoj 1949 Error Correction

    Error Correction Time Limit: 2 Seconds      Memory Limit: 65536 KB A boolean matrix has the parity p ...

  4. QR Code Error Correction

    QR Code Error Correction - QRStuff.com https://blog.qrstuff.com/2011/12/14/qr-code-error-correction ...

  5. POJ 2260(ZOJ 1949) Error Correction 一个水题

    Description A boolean matrix has the parity property when each row and each column has an even sum, ...

  6. POJ 2260

    #include <iostream> #define MAXN 100 using namespace std; int _m[MAXN][MAXN]; int main() { //f ...

  7. [ipsec][strongswan] VirtualPN隧道网络加速FEC(forward error correction)

    引用 跟一个网友就有关IPsec的网络加速以及降低延迟等问题进行了一些讨论,并总结了一写粗浅的看法. 因为FEC的资料并不多,所以分享出来,希望能被有需要的人看见:) 先说一下FEC. 我们使用ips ...

  8. POJ 题目分类(转载)

    Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...

  9. (转)POJ题目分类

    初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推. ...

随机推荐

  1. [Luogu] P1441 砝码称重

    题目描述 现有n个砝码,重量分别为a1,a2,a3,……,an,在去掉m个砝码后,问最多能称量出多少不同的重量(不包括0). 题目分析 因为读错题WAWA大哭. 先dfs枚举选的砝码,满足条件时进行d ...

  2. [GXOI/GZOI2019]宝牌一大堆(dp)

    luogu     bzoj 这个麻将题还算挺友善的,比隔壁zjoi的要好得多... 比较正常的做法是五维dp 但事实上六维dp也是完全不会被卡的 七对子选权值最高的七个,国士无双直接$13^2$暴力 ...

  3. Python学习-列表的其它主要操作

    列表的其它主要操作 还记得之前使用del语句去清除一个列表中的所有内容,那么会因为把列表全部清空,所以输出会报错.可以使用clear() 完成 clear(self):可以将一个列表变成空列表 lis ...

  4. dubbo理解

    Dubbo服务的调用基本上都是出现在分布式项目中,最常见的电商网站.涉及买卖的APP等. 比如某个购物APP,目前最常见的架构就是做成分布式架构,拆分成很多个系统,比如用户模块.短信模块.产品模块.订 ...

  5. 每日命令:(13)more

    more命令,功能类似 cat ,cat命令是整个文件的内容从上到下显示在屏幕上. more会以一页一页的显示方便使用者逐页阅读,而最基本的指令就是按空白键(space)就往下一页显示,按 b 键就会 ...

  6. 详细了解为什么支持Postman Chrome应用程序已被弃用?

    本地postman chrome插件确实也无法正常使用,只有Postman官方自己的软件应用程序可以使用.笔者多少追溯终于知道原因,并紧急上线了不同操作系统版本的Postman应用程序. 为什么近期P ...

  7. 还在为百度网盘下载速度太慢烦恼?chrome浏览器插件帮你解决!

    百度网盘已然成为分享型网盘中一家独大的“大佬”了.时代就是这样不管你喜不喜欢,上网总会遇到些百度网盘共享的文件需要下载.然而,百度网盘对免费用户的限速已经到了“感人”的地步了,常常十多KB/秒的速度真 ...

  8. TCP传输的三次握手四次挥手策略

    为了准确无误地数据送达目标处,TCP协议采用了三次握手策略.用TCP协议把数据包送出去后,TCP不会对传送后的情况置之不理,它一定会向对方确认是否成功送达.握手中使用了TCP的标志:SYN和ACK 发 ...

  9. cookie、localStorage和sessionStorage三者的异同

    1.三者都是用来存储浏览器数据的 2.生命周期:cookie可以设置数据失效时间,默认是关闭浏览器后失效:localStorage中的数据是永久保存的,除非手动清除:sessionStorage的数据 ...

  10. package control(转载)

    Package Control(扩展包管理器)   []Package Control 可以看做是一个ST的扩展管理器,可以去下载.安装.删除 Sublime Text 3的各种插件.皮肤等.   [ ...