QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#646829 | #2598. Permutation Matrix | ship2077 | AC ✓ | 44ms | 8028kb | C++23 | 925b | 2024-10-17 08:57:30 | 2024-10-17 08:57:32 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int M=(1<<10)+5;
int n,m,idx,ans[M][M];
int read(){
int x=0;char ch=getchar();
while (!isdigit(ch)) ch=getchar();
while (isdigit(ch)) x=x*10+ch-48,ch=getchar();
return x;
}
int main(){
scanf("%d",&n);m=1<<n;
if (n==1) return puts("NO"),0;
for (int i=1;i<=m;i++)
if (i&1){
for (int j=1;j<=m;j+=2)
ans[i][j]=++idx;
}
else{
for (int j=m-1;j>0;j-=2)
ans[i][j]=++idx;
}
for (int i=m;i;i--)
if (i&1){
for (int j=m;j>0;j-=2)
ans[i][j]=++idx;
}
else{
for (int j=2;j<=m;j+=2)
ans[i][j]=++idx;
}
puts("YES");
for (int i=1;i<=m;i++)
for (int j=1;j<=m;j++)
printf("%d%c",ans[i][j]," \n"[j==m]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3780kb
input:
1
output:
NO
result:
ok OK.
Test #2:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
2
output:
YES 1 16 2 15 4 13 3 14 5 12 6 11 8 9 7 10
result:
ok OK.
Test #3:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
3
output:
YES 1 64 2 63 3 62 4 61 8 57 7 58 6 59 5 60 9 56 10 55 11 54 12 53 16 49 15 50 14 51 13 52 17 48 18 47 19 46 20 45 24 41 23 42 22 43 21 44 25 40 26 39 27 38 28 37 32 33 31 34 30 35 29 36
result:
ok OK.
Test #4:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
4
output:
YES 1 256 2 255 3 254 4 253 5 252 6 251 7 250 8 249 16 241 15 242 14 243 13 244 12 245 11 246 10 247 9 248 17 240 18 239 19 238 20 237 21 236 22 235 23 234 24 233 32 225 31 226 30 227 29 228 28 229 27 230 26 231 25 232 33 224 34 223 35 222 36 221 37 220 38 219 39 218 40 217 48 209 47 210 46 211 45 2...
result:
ok OK.
Test #5:
score: 0
Accepted
time: 1ms
memory: 4040kb
input:
5
output:
YES 1 1024 2 1023 3 1022 4 1021 5 1020 6 1019 7 1018 8 1017 9 1016 10 1015 11 1014 12 1013 13 1012 14 1011 15 1010 16 1009 32 993 31 994 30 995 29 996 28 997 27 998 26 999 25 1000 24 1001 23 1002 22 1003 21 1004 20 1005 19 1006 18 1007 17 1008 33 992 34 991 35 990 36 989 37 988 38 987 39 986 40 985 ...
result:
ok OK.
Test #6:
score: 0
Accepted
time: 1ms
memory: 5948kb
input:
6
output:
YES 1 4096 2 4095 3 4094 4 4093 5 4092 6 4091 7 4090 8 4089 9 4088 10 4087 11 4086 12 4085 13 4084 14 4083 15 4082 16 4081 17 4080 18 4079 19 4078 20 4077 21 4076 22 4075 23 4074 24 4073 25 4072 26 4071 27 4070 28 4069 29 4068 30 4067 31 4066 32 4065 64 4033 63 4034 62 4035 61 4036 60 4037 59 4038 5...
result:
ok OK.
Test #7:
score: 0
Accepted
time: 0ms
memory: 4476kb
input:
7
output:
YES 1 16384 2 16383 3 16382 4 16381 5 16380 6 16379 7 16378 8 16377 9 16376 10 16375 11 16374 12 16373 13 16372 14 16371 15 16370 16 16369 17 16368 18 16367 19 16366 20 16365 21 16364 22 16363 23 16362 24 16361 25 16360 26 16359 27 16358 28 16357 29 16356 30 16355 31 16354 32 16353 33 16352 34 16351...
result:
ok OK.
Test #8:
score: 0
Accepted
time: 4ms
memory: 6432kb
input:
8
output:
YES 1 65536 2 65535 3 65534 4 65533 5 65532 6 65531 7 65530 8 65529 9 65528 10 65527 11 65526 12 65525 13 65524 14 65523 15 65522 16 65521 17 65520 18 65519 19 65518 20 65517 21 65516 22 65515 23 65514 24 65513 25 65512 26 65511 27 65510 28 65509 29 65508 30 65507 31 65506 32 65505 33 65504 34 65503...
result:
ok OK.
Test #9:
score: 0
Accepted
time: 14ms
memory: 6072kb
input:
9
output:
YES 1 262144 2 262143 3 262142 4 262141 5 262140 6 262139 7 262138 8 262137 9 262136 10 262135 11 262134 12 262133 13 262132 14 262131 15 262130 16 262129 17 262128 18 262127 19 262126 20 262125 21 262124 22 262123 23 262122 24 262121 25 262120 26 262119 27 262118 28 262117 29 262116 30 262115 31 26...
result:
ok OK.
Test #10:
score: 0
Accepted
time: 44ms
memory: 8028kb
input:
10
output:
YES 1 1048576 2 1048575 3 1048574 4 1048573 5 1048572 6 1048571 7 1048570 8 1048569 9 1048568 10 1048567 11 1048566 12 1048565 13 1048564 14 1048563 15 1048562 16 1048561 17 1048560 18 1048559 19 1048558 20 1048557 21 1048556 22 1048555 23 1048554 24 1048553 25 1048552 26 1048551 27 1048550 28 10485...
result:
ok OK.