-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1780.cpp
72 lines (64 loc) · 1.24 KB
/
1780.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
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
vector<vector<int>> v;
int minus1Count;
int zeroCount;
int oneCount;
int cnt;
void solve(int x, int y, int size){
cnt++;
bool flag = false;
int tmp = v[x][y];
for(int i=x; i<x+size; i++){
for(int j=y; j<y+size; j++){
if(v[i][j] != tmp){
flag = true;
break;
}
}
if(flag) break;
}
if(!flag){
if(tmp == -1){
minus1Count++;
}
else if(tmp == 0){
zeroCount++;
}
else{
oneCount++;
}
return;
}
int third = size/3;
for(int i=x; i<x+size; i+=third){
for(int j=y; j<y+size; j+=third){
solve(i,j, third);
}
}
}
int main(void){
int n;
cin>>n;
v.resize(n);
for(auto& each: v){
each.resize(n);
}
int num;
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
cin >> num;
v[i][j] = num;
}
}
minus1Count = 0;
zeroCount = 0;
oneCount =0;
solve(0,0,n);
cout << minus1Count << endl;
cout << zeroCount << endl;
cout << oneCount << endl;
return 0;
}