-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path1514.cpp
106 lines (75 loc) · 1.46 KB
/
1514.cpp
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
101
102
103
104
105
106
#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, tmp;
int matriz[100][100];
bool um(int matriz[100][100]){
bool b = true;
int l;
for (i = 0; i < n; ++i){
l = 0;
for (j = 0; j < m; ++j)
l += matriz[i][j];
if(l == m)
b = false;
}
return b;
}
bool dois(int matriz[100][100]){
int tmp = 0;
bool b = true, b1;
for (i = 0; i < m; ++i){
b1 = false;
for (j = 0; j < n; ++j)
if(matriz[j][i] != 0)
b1 = true;
if(b1) tmp++;
}
if(tmp == m) return true;
else
return false;
}
bool tres(int matriz[100][100]){
bool b = true;
int tmp;
for (i = 0; i < m; ++i){
tmp = 0;
for (j = 0; j < n; ++j)
tmp += matriz[j][i];
if(tmp == n)
b = false;
}
return b;
}
bool quatro(int matriz[100][100]){
int tmp = 0, tmp2 = 0;
for (i = 0; i < n; ++i){
tmp = 0;
for (j = 0; j < m; ++j)
tmp += matriz[i][j];
if(tmp > 0)
tmp2++;
}
if(tmp2 == n) return true;
else
return false;
}
int main()
{
int c;
while(scanf("%d %d", &n, &m), n!= 0 && m !=0){
c = 0;
for (i = 0; i < n; ++i)
for (j = 0; j < m; ++j)
scanf("%d", &matriz[i][j]);
if(um(matriz))
c++;
if(dois(matriz))
c++;
if(tres(matriz))
c++;
if(quatro(matriz))
c++;
printf("%d\n", c);
}
return 0;
}