Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner:

where is equal to 1 if some ai = 1, otherwise it is equal to 0.

Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:

.

(Bij is OR of all elements in row i and column j of matrix A)

Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large.

Input

The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively.

The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1).

Output

In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one.

Sample Input

Input
2 2
1 0
0 0
Output
NO
Input
2 3
1 1 1
1 1 1
Output
YES
1 1 1
1 1 1
Input
2 3
0 1 0
1 1 1
Output
YES
0 0 0
0 1 0
第一次看题目把a,b两个数组看反了,我觉得这道题还是挺好写的,反这写就好了,只要判断a数组当行列上有1的时候对应的b数组是否为1,首先要把a数组复制出来
b数组中为0是,a数组对应的行列都要为0;
 #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int a[][];
int m,n;
void fun(int x,int y)
{
for(int i=;i<=m;i++)
a[i][y]=;
for(int j=;j<=n;j++)
a[x][j]=;
}
int main()
{
int x[],y[];
int b[][];
int i,j;
cin>>m>>n;
for(i=;i<=m;i++)
{
for(j=;j<=n;j++)
a[i][j]=;
}
memset(x,,sizeof(x));
memset(y,,sizeof(y));
for(i=;i<=m;i++)
{
for(j=;j<=n;j++)
{
cin>>b[i][j];
if(b[i][j]==)
fun(i,j);
}
}
/*for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
cout<<a[i][j]<<" ";
cout<<endl;
}*/
for(i=;i<=m;i++)
{
for(j=;j<=n;j++)
{
if(a[i][j]==)
{
x[i]=;
y[j]=;
}
}
}
/*cout<<x[1]<<" "<<x[2]<<endl;
cout<<y[1]<<" "<<y[2]<<endl;*/
int flag=;
for(i=;i<=m;i++)
{
for(j=;j<=n;j++)
{
if(x[i]==||y[j]==)
{
if(b[i][j]==)
flag=;
else
{
cout<<"NO"<<endl;
return ;
}
}
else
{
if(b[i][j]==)
{
cout<<"NO"<<endl;
return ;
}
else
flag=;
}
}
}
if(flag==)
cout<<"YES"<<endl;
for(i=;i<=m;i++)
{
for(j=;j<n;j++)
cout<<a[i][j]<<" ";
cout<<a[i][n]<<endl;
}
return ;
}

CodeForces 486B的更多相关文章

  1. codeforces 486B.OR in Matrix 解题报告

    题目链接:http://codeforces.com/problemset/problem/486/B 题目意思:给出一个m行n列的矩阵B(每个元素只由0/1组成),问是否可以利用矩阵B,通过一定的运 ...

  2. Codeforces 486B - OR in Matrix

    矩阵的 OR ,也是醉了. 题目意思很简单,就是问你有没有这么一个矩阵,可以变化,得到输入的矩阵. 要求是这个矩阵每行都可以上下任意移动,每列都可以左右任意移动. 解题方法: 1.也是导致我WA 的原 ...

  3. 【codeforces】Codeforces Round #277 (Div. 2) 解读

    门户:Codeforces Round #277 (Div. 2) 486A. Calculating Function 裸公式= = #include <cstdio> #include ...

  4. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  5. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  6. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  7. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  8. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  9. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

随机推荐

  1. (转)Vue 爬坑之路(一)—— 使用 vue-cli 搭建项目

    vue-cli 是一个官方发布 vue.js 项目脚手架,使用 vue-cli 可以快速创建 vue 项目,GitHub地址是:https://github.com/vuejs/vue-cli 一. ...

  2. Android MediaRecorder自定义分辨率

    Android MediaRecorder自定义分辨率 工作这么久了,确实积累了不少东西,但都是以文档的形式存在U盘里的,为什么不写博客呢?因为懒啊!!!总感觉博客太难写了(大概是上学时候写作文恐惧症 ...

  3. 偶尔遇到的“The request was aborted:Could not create SSL/TLS secure channel.”怎么解决?

    项目中涉及到调用第三方的Https的WebService,我使用的是原始的HttpWebRequest. 代码中已经考虑到是Https,加上了SSL3协议,加上了委托调用.但偶尔还是会碰到 The r ...

  4. sqlserver 树结构递归(向上递归和向下递归)

    --获取当前及以下部门 Create proc GetCurrentAndUnderOrg @orgId int as begin WITH cte AS ( SELECT * ,0 AS level ...

  5. 【备份工具】mydumper

    Mydumper主要特性:是一个针对MySQL的高性能多线程备份和恢复工具,开发人员主要来自MySQL,Facebook,SkySQL公司. 特性: 1:轻量级C语言写的 2:执行速度比mysqldu ...

  6. dubbo之泛化实现

    实现泛化调用 泛化接口调用方式主要用于客户端没有 API 接口及模型类元的情况,参数及返回值中的所有 POJO 均用 Map 表示,通常用于框架集成,比如:实现一个通用的服务测试框架,可通过 Gene ...

  7. 2016年8月17日 内省(1)18_黑马程序员_使用beanUtils操纵javabean

    8.内省(1):18_黑马程序员_使用beanUtils操纵javabean 1.导入两个包: 2.调用静态方法. 9.泛型 map.entrySet() :取出map集合的键值对组成一个set集合. ...

  8. C#抽奖算法

    摘自网络 static void Main(string[] args) { //各物品的概率保存在数组里 ]{ 0.5f, 0.5f, , }; //单次测试 //Console.WriteLine ...

  9. Tomcat jsp页面显示有问题

    1.干掉tomcat下的work文件夹里面的东西,让jsp文件重新编译,相当于清楚缓存 2.work 里面是 jsp 编译的类 ,只要jsp 被访问了,就会被编译,就会生成相应的类 3.tomcat下 ...

  10. eas之设置编辑界面分录的某一列不可编辑

    KDTEntrys.getColumn(“xx”).getStayAttributes().setlokced(true);