Skip to content

Commit a3aa885

Browse files
authored
Merge pull request #140 from upsk1/Minjo
insert 14601 code
2 parents 3112194 + 58c62fb commit a3aa885

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
int a[1 << 7][1 << 7];
4+
int num;
5+
bool check(int n, int x, int y) {
6+
for (int i = x; i < x + n; i++) {
7+
for (int j = y; j < y + n; j++) {
8+
if (a[i][j])return false;
9+
}
10+
}
11+
return true;
12+
}
13+
void solve(int n, int x, int y) {
14+
num++;
15+
int n2 = n / 2;
16+
if (check(n2, x, y))a[x + n2 - 1][y + n2 - 1] = num;
17+
if (check(n2, x, y + n2))a[x + n2 - 1][y + n2] = num;
18+
if (check(n2, x + n2, y))a[x + n2][y + n2 - 1] = num;
19+
if (check(n2, x + n2, y + n2))a[x + n2][y + n2] = num;
20+
if (n == 2)return;
21+
solve(n2, x, y);
22+
solve(n2, x + n2, y);
23+
solve(n2, x, y + n2);
24+
solve(n2, x + n2, y + n2);
25+
}
26+
int main() {
27+
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
28+
int n;
29+
cin >> n;
30+
n = (1 << n);
31+
int x, y;
32+
cin >> x >> y;
33+
a[n - y][x - 1] = -1;
34+
solve(n, 0, 0);
35+
for (int i = 0; i < n; i++) {
36+
for (int j = 0; j < n; j++) {
37+
cout << a[i][j] << ' ';
38+
}
39+
cout << '\n';
40+
}
41+
42+
}

0 commit comments

Comments
 (0)