-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path60405262.cpp
More file actions
100 lines (100 loc) · 2.1 KB
/
60405262.cpp
File metadata and controls
100 lines (100 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>m>>n;
int row[m];
int col[n];
fill(row,row+m,-1);
fill(col,col+n,-1);
bool ok=true;
vector<int> rows,cols;
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
{
int k;
cin>>k;
if(k==0)
{
if(row[i]==1 || col[j]==1)
{
ok=false;
//cout<<i<<" "<<j<<endl;
}
row[i]=0;
col[j]=0;
}
else // k==1
{
rows.push_back(i);
cols.push_back(j);
}
}
for(int k=0;k<rows.size();k++)
{
int i,j;
i=rows[k];
j=cols[k];
//printf("1 in %d %d\n",i,j);
if(row[i]==0 && col[j]==0)
{
ok=false;
//cout<<i<<" "<<j<<endl;
}
else
{
bool miniok=false;
if(row[i]==0)
{
for(int l=0;l<m;l++)
if(row[l]!=0)
miniok=true;
}
else if(col[j]==0)
{
for(int l=0;l<n;l++)
if(col[l]!=0)
miniok=true;
}
else if(row[i]!=0 && col[j]!=0)
{
continue;
}
if(miniok==false)
{
ok=false;
}
}
/*if(row[i]==-1)
row[i]=1;
if(col[j]==-1)
col[j]=1;*/
}
/*for(int i=0;i<m;i++)
cout<<row[i]<<",";
cout<<endl;
for(int j=0;j<n;j++)
cout<<col[j]<<",";
cout<<endl;*/
if(ok)
{
cout<<"YES"<<endl;
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
if(row[i]!=0 && col[j]!=0)
cout<<"1 ";
else
cout<<"0 ";
}
cout<<endl;
}
}
else
{
cout<<"NO"<<endl;
}
return 0;
}