-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathN2630.cpp
More file actions
56 lines (43 loc) · 796 Bytes
/
Copy pathN2630.cpp
File metadata and controls
56 lines (43 loc) · 796 Bytes
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
#include <iostream>
#include <vector>
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
int N;
int white=0, blue=0;
vector<vector<int>> v;
void solve(int x, int y, int n) {
int temp = 0;
for (int i = x; i < x + n; i++) {
for (int j = y; j < y + n; j++) {
if (v[i][j] == 1) {
temp++;
}
}
}
if (temp == n*n) {
blue++;
}
else if (temp == 0) {
white++;
}
else {
solve(x, y, n / 2);
solve(x, y + n / 2, n / 2);
solve(x + n / 2, y, n / 2);
solve(x + n / 2, y + n / 2, n / 2);
}
}
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 << white << endl;
cout << blue << endl;
return 0;
}