0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-10 02:38:49 +00:00

P5461 赦免战俘

R38778619
This commit is contained in:
Baoshuo Ren 2020-09-23 18:53:04 +08:00 committed by Baoshuo Ren
parent ac0248d390
commit abf981d800
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

42
problem/P5461/P5461.cpp Normal file
View File

@ -0,0 +1,42 @@
// R38778619
#include <bits/stdc++.h>
using namespace std;
int n, p = 1, a[1050][1050];
void dfs(int x, int l, int q) {
if (x == 2) {
a[l][q] = 0;
return;
}
for (int i = l; i <= l + x / 2 - 1; i++) {
for (int j = q; j <= q + x / 2 - 1; j++) {
a[i][j] = 0;
}
}
dfs(x / 2, l + x / 2, q);
dfs(x / 2, l + x / 2, q + x / 2);
dfs(x / 2, l, q + x / 2);
}
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
p *= 2;
}
for (int i = 1; i <= p; i++) {
for (int j = 1; j <= p; j++) {
a[i][j] = 1;
}
}
dfs(p, 1, 1);
for (int i = 1; i <= p; i++) {
for (int j = 1; j <= p - 1; j++) {
cout << a[i][j] << " ";
}
cout << a[i][p] << endl;
}
return 0;
}