This repository has been archived by the owner on May 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uri-1514.cpp
80 lines (70 loc) · 1.42 KB
/
uri-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
#include <iostream>
#include <cstdbool>
#define MAX 100
using namespace std;
int n, m, tmp;
int matriz[MAX][MAX];
bool um(int matriz[MAX][MAX]){
bool b = true;
int l;
for (int i = 0; i < n; ++i){
l = 0;
for (int j = 0; j < m; ++j)
l += matriz[i][j];
if(l == m)
b = false;
}
return b;
}
bool dois(int matriz[MAX][MAX]){
bool b = true, b1;
tmp = 0;
for (int i = 0; i < m; ++i){
b1 = false;
for (int 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[MAX][MAX]){
bool b = true;
for (int i = 0; i < m; ++i){
tmp = 0;
for (int j = 0; j < n; ++j)
tmp += matriz[j][i];
if(tmp == n)
b = false;
}
return b;
}
bool quatro(int matriz[MAX][MAX]){
int tmp2 = 0;
tmp = 0;
for (int i = 0; i < n; ++i){
tmp = 0;
for (int 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((cin >> n >> m) && (n || m)){
c = 0;
for (int i = 0; i < n; ++i)
for (int j = 0; j < m; ++j)
cin >> matriz[i][j];
if(um(matriz)) c++;
if(dois(matriz)) c++;
if(tres(matriz)) c++;
if(quatro(matriz))c++;
cout << c << endl;
}
return 0;
}