QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#124138 | #2598. Permutation Matrix | UNos_maricones | AC ✓ | 50ms | 13308kb | C++20 | 1.9kb | 2023-07-14 09:30:49 | 2023-07-14 09:30:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std ;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> ii;
typedef long double lf;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll SQ = 320;
const ll N = 11;
const ll mod = 1e9 + 7;
const ll oo = 1e18;
long double eps = 1e-9;
int mat[(1<<N)][(1<<N)];
void build (int n) {
if (n == 2) return;
build(n-1);
int b1 = 2 * n - 2, b2 = 2 * n-1;
for (int i = 0; i < (1<<(n-1)); ++i){
for (int j = 0; j < (1<<(n-1)); ++j) {
mat[i + (1<<(n-1))][j] = mat[i][j + (1<<(n-1))] = mat[i + (1<<(n-1))][j + (1<<(n-1))] = mat[i][j];
}
}
for (int i = 0; i < (1<<n); ++i) {
for (int j = 0; j < (1<<n); ++j) {
// int cuad = ((i >= (1<<(n-1))) + (j >= (1<<(n-1))));
if ((i + j) % 2 == (i >= (1<<(n-1))) % 2) {
mat[i][j] |= (1<<b1);
// cout << "on " << b1 << ' ' <<i << ' '<<j << '\n';
}
if ((i + j) % 2 == (j >= (1<<(n-1)))) {
mat[i][j] |= (1<<b2);
// cout << "on " << b2 << ' ' << i << ' '<<j << '\n';
}
}
}
}
int main(){
#ifdef LOCAL
freopen("input.txt","r",stdin);
#endif // LOCAL
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
mat[0][0] = 13;
mat[0][1] = 10;
mat[0][2] = 5;
mat[0][3] = 2;
mat[1][0] = 0;
mat[1][1] = 7;
mat[1][2] = 8;
mat[1][3] = 15;
mat[2][0] = 11;
mat[2][1] = 12;
mat[2][2] = 3;
mat[2][3] = 4;
mat[3][0] = 6;
mat[3][1] = 1;
mat[3][2] = 14;
mat[3][3] = 9;
int n; cin >> n;
if (n == 1) cout << "NO\n";
else {
cout << "YES\n";
build(n);
int curr = -1;
// if (tot.size() < (1<<n)*(1<<n)) cout << "bad\n";
for (int i = 0; i < (1<<n); ++i) {
for (int j = 0; j < (1<<n); ++j) {
cout << mat[i][j] + 1 << ' ';
}
cout << '\n';
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3368kb
input:
1
output:
NO
result:
ok OK.
Test #2:
score: 0
Accepted
time: 0ms
memory: 3460kb
input:
2
output:
YES 14 11 6 3 1 8 9 16 12 13 4 5 7 2 15 10
result:
ok OK.
Test #3:
score: 0
Accepted
time: 1ms
memory: 3432kb
input:
3
output:
YES 62 11 54 3 30 43 22 35 1 56 9 64 33 24 41 32 60 13 52 5 28 45 20 37 7 50 15 58 39 18 47 26 46 27 38 19 14 59 6 51 17 40 25 48 49 8 57 16 44 29 36 21 12 61 4 53 23 34 31 42 55 2 63 10
result:
ok OK.
Test #4:
score: 0
Accepted
time: 1ms
memory: 3512kb
input:
4
output:
YES 254 11 246 3 222 43 214 35 126 139 118 131 94 171 86 163 1 248 9 256 33 216 41 224 129 120 137 128 161 88 169 96 252 13 244 5 220 45 212 37 124 141 116 133 92 173 84 165 7 242 15 250 39 210 47 218 135 114 143 122 167 82 175 90 238 27 230 19 206 59 198 51 110 155 102 147 78 187 70 179 17 232...
result:
ok OK.
Test #5:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
5
output:
YES 1022 11 1014 3 990 43 982 35 894 139 886 131 862 171 854 163 510 523 502 515 478 555 470 547 382 651 374 643 350 683 342 675 1 1016 9 1024 33 984 41 992 129 888 137 896 161 856 169 864 513 504 521 512 545 472 553 480 641 376 649 384 673 344 681 352 1020 13 1012 5 988 45 980 37 892 141 884 133 ...
result:
ok OK.
Test #6:
score: 0
Accepted
time: 2ms
memory: 5804kb
input:
6
output:
YES 4094 11 4086 3 4062 43 4054 35 3966 139 3958 131 3934 171 3926 163 3582 523 3574 515 3550 555 3542 547 3454 651 3446 643 3422 683 3414 675 2046 2059 2038 2051 2014 2091 2006 2083 1918 2187 1910 2179 1886 2219 1878 2211 1534 2571 1526 2563 1502 2603 1494 2595 1406 2699 1398 2691 1374 2731 1366 27...
result:
ok OK.
Test #7:
score: 0
Accepted
time: 0ms
memory: 4084kb
input:
7
output:
YES 16382 11 16374 3 16350 43 16342 35 16254 139 16246 131 16222 171 16214 163 15870 523 15862 515 15838 555 15830 547 15742 651 15734 643 15710 683 15702 675 14334 2059 14326 2051 14302 2091 14294 2083 14206 2187 14198 2179 14174 2219 14166 2211 13822 2571 13814 2563 13790 2603 13782 2595 13694 269...
result:
ok OK.
Test #8:
score: 0
Accepted
time: 5ms
memory: 5700kb
input:
8
output:
YES 65534 11 65526 3 65502 43 65494 35 65406 139 65398 131 65374 171 65366 163 65022 523 65014 515 64990 555 64982 547 64894 651 64886 643 64862 683 64854 675 63486 2059 63478 2051 63454 2091 63446 2083 63358 2187 63350 2179 63326 2219 63318 2211 62974 2571 62966 2563 62942 2603 62934 2595 62846 269...
result:
ok OK.
Test #9:
score: 0
Accepted
time: 10ms
memory: 7728kb
input:
9
output:
YES 262142 11 262134 3 262110 43 262102 35 262014 139 262006 131 261982 171 261974 163 261630 523 261622 515 261598 555 261590 547 261502 651 261494 643 261470 683 261462 675 260094 2059 260086 2051 260062 2091 260054 2083 259966 2187 259958 2179 259934 2219 259926 2211 259582 2571 259574 2563 25955...
result:
ok OK.
Test #10:
score: 0
Accepted
time: 50ms
memory: 13308kb
input:
10
output:
YES 1048574 11 1048566 3 1048542 43 1048534 35 1048446 139 1048438 131 1048414 171 1048406 163 1048062 523 1048054 515 1048030 555 1048022 547 1047934 651 1047926 643 1047902 683 1047894 675 1046526 2059 1046518 2051 1046494 2091 1046486 2083 1046398 2187 1046390 2179 1046366 2219 1046358 2211 10460...
result:
ok OK.