-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathN1780.cpp
More file actions
65 lines (54 loc) · 1.18 KB
/
Copy pathN1780.cpp
File metadata and controls
65 lines (54 loc) · 1.18 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
#include <iostream>
#include<vector>>
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
vector<vector<int>> v;
int N;
int res_minus = 0, res_plus = 0, res_zero = 0;
void solve(int x, int y, int n) {
int temp_zero = 0;
int temp_plus = 0;
for (int i = x; i < x+n; i++) {
for (int j = y; j < y+n; j++) {
if (v[i][j] == 0) {
temp_zero++;
}
else if (v[i][j] == 1) {
temp_plus++;
}
}
}
if (temp_zero == 0 && temp_plus == 0) {
res_minus++;
}else if (temp_zero == n * n) {
res_zero++;
}else if (temp_plus == n * n) {
res_plus++;
}
else {
solve(x, y, n / 3);
solve(x + n / 3, y, n / 3);
solve(x, y + n / 3, n / 3);
solve(x + n / 3, y + n / 3, n / 3);
solve(x + n * 2 / 3, y, n / 3);
solve(x, y + n * 2 / 3, n / 3);
solve(x + n * 2 / 3, y + n / 3, n / 3);
solve(x + n / 3, y + n * 2 / 3, n / 3);
solve(x + n * 2 / 3, y + n * 2 / 3, n / 3);
}
}
int main(void) {
FASTIO;
cin >> N;
v.resize(N, vector<int>(N));
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
cin >> v[i][j];
}
}
solve(0, 0, N);
cout << res_minus << endl;
cout << res_zero << endl;
cout << res_plus << endl;
return 0;
}