sicily--1819. Matrix
来源:互联网 发布:淘宝精品店 编辑:程序博客网 时间:2024/05/18 03:36
一开始,真的是被这道题打败了,无论如何都 TL;
不知道怎么去用bitset或者是随机算法,后请教了一个大牛师兄,学习了他的代码让我真正的理解了这样的原因
另收集了一些关于 “bitset”的用法:http://blog.csdn.net/chenhq1991/article/details/7758984
#include<cstdio>#include<bitset>using namespace std;bitset<1000> a[1000], b[1000], c[1000];int size;bool correct(){ for(int i = 0; i < size; i ++) { for(int j=0;j<size;j++) { if((a[i] & b[j]).count() % 2 == 0)//结果中‘1’的个数 { if(c[i][j] == 1)return false; } else { if(c[i][j] == 0)return false; } } } return true;}int main(){ int testcase; char ch; scanf("%d",&testcase); while(testcase --) { scanf("%d",&size); for(int i=0;i<size;i++) { a[i].reset();//初始化为0 b[i].reset(); c[i].reset(); } for(int i = 0; i < size; i ++) { getchar();//回车 for(int j = 0; j < size; j ++) { ch = getchar(); if(ch == '1')a[i].set(j); } } for(int i = 0; i < size; i ++) { getchar(); for(int j = 0; j < size; j ++) { ch = getchar(); if(ch == '1') b[j].set(i);//倒置 } } for(int i = 0; i < size; i ++) { getchar(); for(int j = 0; j < size; j ++) { ch = getchar(); if ( ch == '1') c[i].set(j); } } if( correct() ) printf("YES\n"); else printf("NO\n"); }}
- sicily--1819. Matrix
- Sicily 1819. Matrix
- Sicily 1819. Matrix
- Sicily 3712. Matrix multiplication
- soj 1819. Matrix
- 《Matrix》
- Matrix
- Matrix
- Matrix
- Matrix
- Matrix
- Matrix
- mAtrix
- Matrix
- matrix
- Matrix
- Matrix
- Matrix
- 举例说明android中实现发送邮件的方法
- android学习(第三篇 页面组件编程)
- 计算一个程序的执行时间和定时器
- android网络编程所涉及到的知识
- Twisted服务器开发技巧(1)
- sicily--1819. Matrix
- multieditor
- 几种开源TCP/IP协议栈概述
- ORA-00600:[32695], [hash aggregation can't be done] 解决方法
- Excel使用技巧大全(一)
- GEF MultiEditor
- Android文件操作总结
- Socket简单实例
- mutieditor