-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOR_IN_Matrix.java
More file actions
56 lines (55 loc) · 1.48 KB
/
OR_IN_Matrix.java
File metadata and controls
56 lines (55 loc) · 1.48 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
import java.io.*;
import java.util.*;
import java.lang.*;
public class OR_IN_Matrix{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
List<Integer> l = new ArrayList<>();
int i,j,m,n,t;
m = sc.nextInt();
n = sc.nextInt();
int[][] a = new int[m][n];
int[][] b = new int[m][n];
int[][] c = new int[m][n];
for(i=0;i<m;i++){
for(j=0;j<n;j++){
b[i][j] = sc.nextInt();
a[i][j]=1;
c[i][j]=0;
}
}
for(i=0;i<m;i++){
for(j=0;j<n;j++){
if(b[i][j]==0){
for(t=0;t<m;t++){
a[t][j]=0;
}
for(t=0;t<n;t++){
a[i][t]=0;
}
}
}
}
for(i=0;i<m;i++){
for(j=0;j<n;j++){
for(t=0;t<m;t++){
c[i][j] = c[i][j] | a[t][j];
}
for(t=0;t<n;t++){
c[i][j] = c[i][j] | a[i][t];
}
if(c[i][j]!=b[i][j]){
System.out.println("NO");
System.exit(0);
}
}
}
System.out.println("YES");
for(i=0;i<m;i++){
for(j=0;j<n;j++){
System.out.print(a[i][j]+" ");
}
System.out.println();
}
}
}