QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#49610 | #2598. Permutation Matrix | Crysfly | AC ✓ | 86ms | 3656kb | C++11 | 818b | 2022-09-22 08:52:16 | 2022-09-22 08:52:30 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(register int i=(a);i>=(b);--i)
#define int long long
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 2000005
#define inf 0x3f3f3f3f
int n,s,l,r;
signed main()
{
n=read();
if(n==1)puts("NO"),exit(0);
s=(1<<(n*2));
int l=1,r=s;
puts("YES");
For(i,1,(1<<n))
For(j,1,(1<<n)){
if((i+j)%2==0)cout<<l,++l;
else cout<<r,--r;
cout<<" \n"[j==(1<<n)];
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3484kb
input:
1
output:
NO
result:
ok OK.
Test #2:
score: 0
Accepted
time: 2ms
memory: 3656kb
input:
2
output:
YES 1 16 2 15 14 3 13 4 5 12 6 11 10 7 9 8
result:
ok OK.
Test #3:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
3
output:
YES 1 64 2 63 3 62 4 61 60 5 59 6 58 7 57 8 9 56 10 55 11 54 12 53 52 13 51 14 50 15 49 16 17 48 18 47 19 46 20 45 44 21 43 22 42 23 41 24 25 40 26 39 27 38 28 37 36 29 35 30 34 31 33 32
result:
ok OK.
Test #4:
score: 0
Accepted
time: 2ms
memory: 3548kb
input:
4
output:
YES 1 256 2 255 3 254 4 253 5 252 6 251 7 250 8 249 248 9 247 10 246 11 245 12 244 13 243 14 242 15 241 16 17 240 18 239 19 238 20 237 21 236 22 235 23 234 24 233 232 25 231 26 230 27 229 28 228 29 227 30 226 31 225 32 33 224 34 223 35 222 36 221 37 220 38 219 39 218 40 217 216 41 215 42 214 43 213 ...
result:
ok OK.
Test #5:
score: 0
Accepted
time: 2ms
memory: 3556kb
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 1008 17 1007 18 1006 19 1005 20 1004 21 1003 22 1002 23 1001 24 1000 25 999 26 998 27 997 28 996 29 995 30 994 31 993 32 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: 3ms
memory: 3656kb
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 4064 33 4063 34 4062 35 4061 36 4060 37 4059 38 4...
result:
ok OK.
Test #7:
score: 0
Accepted
time: 0ms
memory: 3512kb
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: 8ms
memory: 3544kb
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: 11ms
memory: 3616kb
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: 86ms
memory: 3552kb
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.