QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#393103 | #2598. Permutation Matrix | ucup-team2580# | AC ✓ | 40ms | 11740kb | C++23 | 1.1kb | 2024-04-18 09:55:21 | 2024-04-18 09:55:22 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
int ans[2020][2020];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
if(n==1)
die("NO");
cout<<"YES\n";
int A=1,B=(1<<n+n);
for(int i=0;i<(1<<n);i++)
{
for(int j=0;j<(1<<n);j++)
if((i+j)&1)
{
ans[i][j]=A;
A+=2;
}
else
{
ans[i][j]=B;
B-=2;
}
}
for(int i=0;i<(1<<n);i++)
{
for(int j=0;j<(1<<n);j++)
cout<<ans[i][j]<<" ";
cout<<'\n';
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
input:
1
output:
NO
result:
ok OK.
Test #2:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
2
output:
YES 16 1 14 3 5 12 7 10 8 9 6 11 13 4 15 2
result:
ok OK.
Test #3:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
3
output:
YES 64 1 62 3 60 5 58 7 9 56 11 54 13 52 15 50 48 17 46 19 44 21 42 23 25 40 27 38 29 36 31 34 32 33 30 35 28 37 26 39 41 24 43 22 45 20 47 18 16 49 14 51 12 53 10 55 57 8 59 6 61 4 63 2
result:
ok OK.
Test #4:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
4
output:
YES 256 1 254 3 252 5 250 7 248 9 246 11 244 13 242 15 17 240 19 238 21 236 23 234 25 232 27 230 29 228 31 226 224 33 222 35 220 37 218 39 216 41 214 43 212 45 210 47 49 208 51 206 53 204 55 202 57 200 59 198 61 196 63 194 192 65 190 67 188 69 186 71 184 73 182 75 180 77 178 79 81 176 83 174 85...
result:
ok OK.
Test #5:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
5
output:
YES 1024 1 1022 3 1020 5 1018 7 1016 9 1014 11 1012 13 1010 15 1008 17 1006 19 1004 21 1002 23 1000 25 998 27 996 29 994 31 33 992 35 990 37 988 39 986 41 984 43 982 45 980 47 978 49 976 51 974 53 972 55 970 57 968 59 966 61 964 63 962 960 65 958 67 956 69 954 71 952 73 950 75 948 77 946 79 944 81...
result:
ok OK.
Test #6:
score: 0
Accepted
time: 1ms
memory: 5808kb
input:
6
output:
YES 4096 1 4094 3 4092 5 4090 7 4088 9 4086 11 4084 13 4082 15 4080 17 4078 19 4076 21 4074 23 4072 25 4070 27 4068 29 4066 31 4064 33 4062 35 4060 37 4058 39 4056 41 4054 43 4052 45 4050 47 4048 49 4046 51 4044 53 4042 55 4040 57 4038 59 4036 61 4034 63 65 4032 67 4030 69 4028 71 4026 73 4024 75 4...
result:
ok OK.
Test #7:
score: 0
Accepted
time: 1ms
memory: 4404kb
input:
7
output:
YES 16384 1 16382 3 16380 5 16378 7 16376 9 16374 11 16372 13 16370 15 16368 17 16366 19 16364 21 16362 23 16360 25 16358 27 16356 29 16354 31 16352 33 16350 35 16348 37 16346 39 16344 41 16342 43 16340 45 16338 47 16336 49 16334 51 16332 53 16330 55 16328 57 16326 59 16324 61 16322 63 16320 65 1631...
result:
ok OK.
Test #8:
score: 0
Accepted
time: 0ms
memory: 6776kb
input:
8
output:
YES 65536 1 65534 3 65532 5 65530 7 65528 9 65526 11 65524 13 65522 15 65520 17 65518 19 65516 21 65514 23 65512 25 65510 27 65508 29 65506 31 65504 33 65502 35 65500 37 65498 39 65496 41 65494 43 65492 45 65490 47 65488 49 65486 51 65484 53 65482 55 65480 57 65478 59 65476 61 65474 63 65472 65 6547...
result:
ok OK.
Test #9:
score: 0
Accepted
time: 13ms
memory: 7112kb
input:
9
output:
YES 262144 1 262142 3 262140 5 262138 7 262136 9 262134 11 262132 13 262130 15 262128 17 262126 19 262124 21 262122 23 262120 25 262118 27 262116 29 262114 31 262112 33 262110 35 262108 37 262106 39 262104 41 262102 43 262100 45 262098 47 262096 49 262094 51 262092 53 262090 55 262088 57 262086 59 2...
result:
ok OK.
Test #10:
score: 0
Accepted
time: 40ms
memory: 11740kb
input:
10
output:
YES 1048576 1 1048574 3 1048572 5 1048570 7 1048568 9 1048566 11 1048564 13 1048562 15 1048560 17 1048558 19 1048556 21 1048554 23 1048552 25 1048550 27 1048548 29 1048546 31 1048544 33 1048542 35 1048540 37 1048538 39 1048536 41 1048534 43 1048532 45 1048530 47 1048528 49 1048526 51 1048524 53 1048...
result:
ok OK.