HRBUST 2219 Recover the Matrix(水题)
来源:互联网 发布:辣鸡软件表情 编辑:程序博客网 时间:2024/06/08 05:32
Time Limit: 1000 MSMemory Limit: 32768 KTotal Submit: 2(2 users)Total Accepted: 1(1 users)Rating: Special Judge: NoDescriptionGiven two n * m matrix a containing only 1 and 0. Bob will generate a new n * m matrix b. Each element b[i][j] in matrix b is the OR operation result of every elements in the same row or same column with b[i][j]. (b[i][j] = a[0][j] | a[1][j] | ... | a[n][j] | a[i][0] | a[i][1] | ... | a[i][m]).Bob sometimes makes mistakes. So we will give you matrix b and let you determine whether Bob has made a mistake. If not, you need to output if there is a possible original matrix.
InputFirst line of input contains only integer T, indicating the number of test cases.
First line of each test case contains two integer n and m (the numbers of rows and columns of the matrix won't exceed 100).
Then n lines follows, each line contains m numbers describing the matrix. Each numbers can only be 1 or 0.
OutputFor each test case, if Bob made no mistake, output "YES". Output "NO" if he did.Sample Input2
2 2
1 0
0 0
2 3
1 1 1
1 1 1
Sample OutputNO
YES
#include<stdio.h>#include<string.h>using namespace std;int a[1003][1003];int main(){ int t; scanf("%d",&t); while(t--) { int n,m; scanf("%d%d",&n,&m); for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { scanf("%d",&a[i][j]); } } int f=0; for(int j=0;j<m;j++) { int tem=a[0][j]; for(int i=1;i<n;i++) { if(a[i][j]!=tem) f=1; } } if(f) printf("NO\n"); else printf("YES\n"); }}
0 0
- HRBUST 2219 Recover the Matrix(水题)
- codeforces Recover the String
- [codeforces]Recover the String
- The matrix
- The Matrix
- The Matrix
- 1038. Recover the Smallest Number
- PAT_1038: Recover the Smallest Number
- Check the recover datafile header
- 1038. Recover the Smallest Number
- 1038. Recover the Smallest Number
- 1038. Recover the Smallest Number
- pat1038 Recover the Smallest Number
- 1038. Recover the Smallest Number
- 1038 Recover the Smallest Number
- Recover the Smallest Number (30)
- 1038. Recover the Smallest Number
- pat1038. Recover the Smallest Number
- JMeter学习笔记12-如何录制WebUI脚本
- 【精华版】数据库范式
- 1022: 斐波纳契数列
- 实例探索Java模式之路——单例模式
- JS 操作cookie 设置cookie、读取cookie、删除cookie
- HRBUST 2219 Recover the Matrix(水题)
- 按键驱动(等待队列+设备树+属性文件)
- 网络版免费分床裁剪计划软件V4.0正式公测
- 用Java对JSON字符串进行格式化输出
- 字符串过滤
- LinuxC学习笔记
- 大数据的价值是如何得以彰显的?
- 深度学习
- JAVA报错:Variable 'vv' is accessed from within inner class, needs to be declared final