QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#749917 | #4252. Permutation | KiharaTouma | 100 ✓ | 1ms | 4108kb | C++23 | 1.8kb | 2024-11-15 11:23:03 | 2024-11-15 11:23:08 |
Judging History
answer
//qoj4252
#include <bits/stdc++.h>
using namespace std;
vector<int> construct_permutation(long long k){
vector<int> rs, tmp;
long long mx = 1;
int cnt = 0, nw = 0, flg = 0, mn = 0, cmn = 0, cq = 1;
while(mx * 2 <= k){
mx *= 2;
++ cnt;
}
k -= mx;
for(int i = 0; i < cnt; ++ i){
rs.push_back(i);
if(flg){
rs.push_back(cmn + 100 - cq);
++ cq;
k -= 1ll << cnt - i - 0;
k -= 1ll << cnt - i - 1;
flg = 0;
} else if(nw >= 2 && ((k>>cnt-i-1) & 1) && ((k>>cnt-i-2) & 1)){
flg = 1;
} else if((k>>cnt-i-1) & 1){
rs.push_back(-i*1000 - 2666);
cmn = mn;
mn = -i * 1000 - 2666;
cq = 0;
k -= 1ll << cnt - i - 1;
++ nw;
}
}
for(int i = 0; i < rs.size(); ++ i){
int x = 0;
for(int j = 0; j < rs.size(); ++ j){
if(rs[j] < rs[i]){
++ x;
}
}
tmp.push_back(x);
}
return tmp;
}
#ifndef ONLINE_JUDGE
int main(){
int q, k;
scanf("%d", &q);
while(q--){
long long n;
scanf("%lld", &n);
vector<int> rs = construct_permutation(n);
printf("%d\n", rs.size());
for(int i : rs){
printf("%d ", i);
}
puts("");
int len = rs.size();
long long ans = 1;
static long long f[1010];
for(int i = 0; i < len; ++ i){
f[i] = 1;
for(int j = 0; j < i; ++ j){
if(rs[j] < rs[i]){
f[i] += f[j];
}
}
ans += f[i];
}
printf("%lld\n", ans);
}
}
#endif
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 1ms
memory: 3828kb
input:
a92b3f80-b312-8377-273c-3916024d7f2a 89 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
output:
6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf OK 1 0 2 1 0 2 0 1 3 1 2 0 3 1 0 2 4 2 1 3 0 3 0 1 2 4 1 2 3 0 4 1 2 0 3 5 2 3 1 4 0 4 1 0 2 3 5 2 1 3 4 0 5 2 1 3 0 4 6 3 2 4 1 5 0 4 0 1 2 3 5 1 2 3 4 0 5 1 2 3 0 4 6 2 3 4 1 5 0 5 1 2 0 3 4 6 2 3 1 4 5 0 6 2 3 1 4 0 5 7 3 4 2 5 1 6 0 5 1 0 2 3 4 6 2 1 3 4 5 0 ...
result:
ok
Subtask #2:
score: 90
Accepted
Test #2:
score: 90
Accepted
time: 1ms
memory: 3784kb
input:
a92b3f80-b312-8377-273c-3916024d7f2a 100 39993 85709 48645 25391 15360 54084 28947 18808 86735 316 14357 82845 96210 16242 58466 43439 77462 70742 76176 20397 30314 22634 29622 81835 31904 81283 37072 36527 26764 55878 72762 5262 34915 63468 20595 66579 77373 36670 89340 83384 73268 31960 67318 3908...
output:
6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf OK 21 6 7 8 5 9 3 10 2 11 12 13 14 15 16 4 17 1 18 19 20 0 22 6 7 2 8 9 10 1 11 12 5 13 14 15 4 16 17 18 19 3 20 21 0 21 6 7 4 8 3 9 10 5 11 2 12 13 14 15 16 17 18 1 19 20 0 20 6 5 7 8 9 10 4 11 1 12 13 14 0 15 16 17 3 18 19 2 16 3 2 4 1 5 0 6 7 8 9 10 11 12 13 1...
result:
ok
Test #3:
score: 90
Accepted
time: 1ms
memory: 4108kb
input:
a92b3f80-b312-8377-273c-3916024d7f2a 100 2147483647 1073741823 536870911 268435455 134217727 67108863 33554431 16777215 8388607 4194303 2097151 1582 24319 38 463 7 1073741503 3 18 3 3780 2 24934 124910 65535 154 1069539071 209452285 1662 3 3 93 4070 131071 502986749 3164 268430159 247 21746 124927 1...
output:
6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf OK 46 16 1 17 0 18 19 15 20 21 14 22 23 13 24 25 12 26 27 11 28 29 10 30 31 9 32 33 8 34 35 7 36 37 6 38 39 5 40 41 4 42 43 3 44 45 2 45 16 2 17 1 18 19 15 20 21 14 22 23 13 24 25 12 26 27 11 28 29 10 30 31 9 32 33 8 34 35 7 36 37 6 38 39 5 40 41 4 42 43 3 44 0 4...
result:
ok
Test #4:
score: 90
Accepted
time: 1ms
memory: 3836kb
input:
a92b3f80-b312-8377-273c-3916024d7f2a 100 576460752303423487 288230376151711743 144115188075855871 72057594037927935 36028797018963967 18014398509481983 9007199254740991 4503599627370495 2251799813685247 1125899906842623 562949953421311 8166608599550 16508780543 33554427 43000192155799 62353919 71773...
output:
6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf OK 88 30 1 31 0 32 33 29 34 35 28 36 37 27 38 39 26 40 41 25 42 43 24 44 45 23 46 47 22 48 49 21 50 51 20 52 53 19 54 55 18 56 57 17 58 59 16 60 61 15 62 63 14 64 65 13 66 67 12 68 69 11 70 71 10 72 73 9 74 75 8 76 77 7 78 79 6 80 81 5 82 83 4 84 85 3 86 87 2 87 ...
result:
ok
Test #5:
score: 90
Accepted
time: 1ms
memory: 3892kb
input:
a92b3f80-b312-8377-273c-3916024d7f2a 100 336455856505 197522918480 260689715591 857530435844 89809708292 207893569808 702779448503 917149928374 643600357316 927175148543 51879726697 974331197849 721971572596 902469653832 936157710917 714588060426 276939435899 393954173900 692525720126 762289367234 1...
output:
6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf OK 53 15 16 17 14 18 13 19 12 20 21 22 10 23 24 9 25 26 27 11 28 29 30 8 31 32 5 33 34 2 35 36 37 38 7 39 40 6 41 42 43 44 1 45 46 47 4 48 49 3 50 51 52 0 50 13 14 9 15 8 16 17 18 12 19 20 11 21 22 10 23 7 24 25 6 26 27 5 28 29 30 3 31 32 33 34 2 35 36 37 38 39 4...
result:
ok
Test #6:
score: 90
Accepted
time: 1ms
memory: 3792kb
input:
a92b3f80-b312-8377-273c-3916024d7f2a 100 330061280882697 570108406837011 246465711199350 844437948491708 542197441405836 481743322695013 913237337833838 634038564781156 969749245791701 445335878892049 722391184659757 25600568975288 304176471716316 934030664268458 770565383569314 38589802113902 56387...
output:
6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf OK 60 12 13 14 11 15 16 8 17 5 18 19 20 21 22 23 10 24 25 26 27 28 29 30 9 31 32 33 34 35 3 36 37 38 7 39 40 41 42 6 43 44 2 45 46 47 4 48 49 50 51 52 53 54 55 56 1 57 58 59 0 65 16 17 18 19 20 21 22 15 23 14 24 25 13 26 27 28 29 30 31 11 32 33 10 34 35 36 12 37 ...
result:
ok
Test #7:
score: 90
Accepted
time: 1ms
memory: 3804kb
input:
a92b3f80-b312-8377-273c-3916024d7f2a 100 9808783958425241 800256975993528789 891794666437715812 154809014071580277 262143300778136084 508038278751820218 855062810898478629 196129157832150290 519747744582635554 544132224659269080 335568667826635843 978219202156109836 887928188166976766 57068450616591...
output:
6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf OK 72 19 20 21 22 18 23 24 16 25 15 26 27 28 17 29 30 31 14 32 33 34 35 36 10 37 38 39 9 40 41 42 13 43 44 12 45 46 47 11 48 8 49 50 51 52 53 5 54 55 4 56 57 58 59 7 60 61 6 62 2 63 64 1 65 66 67 68 3 69 70 71 0 81 22 23 19 24 18 25 26 27 28 29 21 30 31 32 20 33 ...
result:
ok
Test #8:
score: 90
Accepted
time: 1ms
memory: 3836kb
input:
a92b3f80-b312-8377-273c-3916024d7f2a 100 576460752303423488 576460752303423489 576460752303423490 576460752303423491 576460752303423492 576460752303423493 576460752303423494 576460752303423495 576460752303423496 576460752303423497 576460752303423498 576460752303423499 576460752303423500 576460752303...
output:
6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf OK 59 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ...
result:
ok
Test #9:
score: 90
Accepted
time: 1ms
memory: 3808kb
input:
a92b3f80-b312-8377-273c-3916024d7f2a 100 999999999999999901 999999999999999902 999999999999999903 999999999999999904 999999999999999905 999999999999999906 999999999999999907 999999999999999908 999999999999999909 999999999999999910 999999999999999911 999999999999999912 999999999999999913 999999999999...
output:
6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf OK 83 24 22 25 26 21 27 28 23 29 18 30 31 32 33 34 35 15 36 37 38 20 39 40 41 19 42 43 14 44 45 46 17 47 48 49 50 16 51 12 52 53 5 54 55 56 57 13 58 3 59 60 61 11 62 63 64 65 66 10 67 68 9 69 70 8 71 72 7 73 74 6 75 2 76 77 78 79 4 80 1 81 82 0 82 23 21 24 25 20 ...
result:
ok
Test #10:
score: 90
Accepted
time: 1ms
memory: 3808kb
input:
a92b3f80-b312-8377-273c-3916024d7f2a 100 333271685633113373 303681151173201623 185954994672690293 695000491456721509 680039555562404861 711731044985538439 725639770789026979 653124604194000671 716161846351295353 727816570890872159 566821251164212697 620956504691616073 845196440395453799 654653854021...
output:
6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf OK 77 19 20 21 18 22 23 16 24 25 26 27 28 29 30 31 32 33 34 15 35 36 37 38 17 39 40 14 41 42 13 43 44 6 45 46 47 48 5 49 50 51 52 12 53 54 11 55 56 57 10 58 59 60 9 61 62 63 8 64 65 7 66 3 67 68 2 69 70 71 72 73 4 74 1 75 76 0 79 21 22 23 24 25 18 26 17 27 28 29 ...
result:
ok
Test #11:
score: 90
Accepted
time: 1ms
memory: 3844kb
input:
a92b3f80-b312-8377-273c-3916024d7f2a 100 11260605527954640 3776579230632 1586488757700 753903936556020250 10601397297904140 810787108223734551 544021594614225000 609804018090927660 212587386929622705 334981274861463750 759012209987031 879302565815602500 156896254323644472 501935537823034315 23356411...
output:
6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf OK 66 13 14 11 15 16 17 18 19 20 21 22 23 24 25 9 26 27 28 12 29 7 30 31 32 10 33 34 35 36 37 38 5 39 40 41 42 43 44 8 45 4 46 47 48 49 6 50 51 52 53 2 54 55 1 56 57 58 59 3 60 61 0 62 63 64 65 58 17 16 18 19 13 20 10 21 22 23 15 24 25 14 26 27 9 28 29 30 31 12 3...
result:
ok
Test #12:
score: 90
Accepted
time: 1ms
memory: 3856kb
input:
a92b3f80-b312-8377-273c-3916024d7f2a 100 450283905890997362 288230376151711743 298023223876953124 789730223053602815 558545864083284006 144115188075855871 150094635296999120 999999999999999999 505447028499293770 184884258895036415 665416609183179840 155568095557812223 437893890380859374 720575940379...
output:
6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf OK 82 24 19 25 26 27 28 18 29 30 23 31 32 22 33 34 21 35 36 37 20 38 16 39 40 14 41 42 43 17 44 45 13 46 47 48 49 15 50 12 51 52 11 53 54 55 56 9 57 58 8 59 60 61 10 62 63 7 64 65 6 66 67 5 68 69 3 70 71 2 72 73 74 75 76 4 77 1 78 79 80 0 81 87 30 2 31 1 32 33 29...
result:
ok
Extra Test:
score: 0
Extra Test Passed