-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathN1992.cpp
More file actions
53 lines (43 loc) · 918 Bytes
/
Copy pathN1992.cpp
File metadata and controls
53 lines (43 loc) · 918 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
#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;
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++;
}
}
}
cout << "(";
if (temp == 0) {
cout << "0";
}
else if (temp == n * n) {
cout << "1";
}
else {
solve(x, y, n / 2);
solve(x + n / 2, y, n / 2);
solve(x, y + n / 2, n / 2);
solve(x+ n / 2, y+ n / 2, n / 2);
}
cout << ")";
return;
}
int main() {
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);
return 0;
}