QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#786846 | #4252. Permutation | isirazeev | 100 ✓ | 1ms | 4104kb | C++23 | 1.3kb | 2024-11-27 00:04:53 | 2024-11-27 00:04:54 |
Judging History
answer
#include <bits/stdc++.h>
#include "perm.h"
using namespace std;
void mul2(vector<int> &p) {
p.emplace_back((int) p.size());
}
void add1(vector<int> &p) {
for (int &i: p) i++;
p.emplace_back(0);
}
bool isGood(vector<int> p) {
int pos1, pos0;
for (int i = 0; i < (int) p.size(); i++) {
if (p[i] == 1) pos1 = i;
if (p[i] == 0) pos0 = i;
}
return pos1 < pos0;
}
std::vector<int> construct_permutation(long long k) {
vector<int> operations;
while (k > 4) {
operations.emplace_back(k % 4);
k /= 4;
}
vector<int> res;
if (k == 2) res = {0};
else if (k == 3) res = {1, 0};
else if (k == 4) res = {0, 1};
reverse(operations.begin(), operations.end());
for (int r: operations) {
if (r == 0) {
mul2(res), mul2(res);
} else if (r == 1) {
mul2(res), mul2(res), add1(res);
} else if (r == 2) {
mul2(res), add1(res), mul2(res);
} else {
if (!res.empty() && isGood(res)) {
mul2(res), mul2(res);
for (int &i: res)
if (i > 1) ++i;
res.emplace_back(2);
} else {
mul2(res), add1(res), mul2(res), add1(res);
}
}
}
return res;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 1ms
memory: 3792kb
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 5 1 0 3 4 2 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 6 1 3 0 4 5 2 5 1 0 2 3 4 6 2 1 3 4 5 0 6 2 ...
result:
ok
Subtask #2:
score: 90
Accepted
Test #2:
score: 90
Accepted
time: 0ms
memory: 4104kb
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 20 3 6 7 2 8 9 5 10 11 12 13 14 15 4 16 1 17 18 19 0 22 5 7 2 8 9 10 11 6 12 1 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 19 4 1 6 7 8 9 10 5 11 12 13 0 14 15 16 3 17 18 2 15 1 0 3 4 2 5 6 7 8 9 10 11 12 13 14 20 5...
result:
ok
Test #3:
score: 90
Accepted
time: 1ms
memory: 3864kb
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 44 1 0 16 17 15 18 19 14 20 21 13 22 23 12 24 25 11 26 27 10 28 29 9 30 31 8 32 33 7 34 35 6 36 37 5 38 39 4 40 41 3 42 43 2 43 1...
result:
ok
Test #4:
score: 90
Accepted
time: 1ms
memory: 4052kb
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 86 ...
result:
ok
Test #5:
score: 90
Accepted
time: 1ms
memory: 3824kb
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 55 17 18 19 16 20 15 21 14 22 23 24 13 25 26 12 27 28 11 29 10 30 31 32 9 33 34 6 35 36 5 37 38 39 40 8 41 42 7 43 44 45 46 3 47 48 2 49 50 4 51 1 52 53 54 0 50 13 14 12 15 8 16 17 7 18 19 11 20 21 10 22 23 9 24 25 6 26 27 5 28 29 30 3 31 32 33 34 2 35 36 37 3...
result:
ok
Test #6:
score: 90
Accepted
time: 0ms
memory: 3776kb
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 62 12 15 16 11 17 18 19 14 20 21 22 23 24 25 13 26 27 28 29 30 31 10 32 9 33 34 35 36 37 8 38 39 7 40 6 41 42 43 5 44 3 45 46 2 47 48 49 4 50 51 52 53 54 55 56 57 58 1 59 60 61 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 ...
result:
ok
Test #7:
score: 90
Accepted
time: 1ms
memory: 4068kb
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 74 20 22 23 24 19 25 26 27 21 28 29 18 30 17 31 32 33 16 34 35 36 37 38 15 39 40 41 13 42 43 11 44 45 14 46 10 47 48 49 12 50 9 51 52 53 54 55 6 56 57 5 58 59 60 61 8 62 63 7 64 4 65 66 3 67 68 69 2 70 1 71 72 73 0 84 25 26 24 27 23 28 29 30 31 21 32 20 33 34 ...
result:
ok
Test #8:
score: 90
Accepted
time: 1ms
memory: 4024kb
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: 0ms
memory: 3784kb
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 85 26 24 27 28 23 29 30 25 31 21 32 33 34 35 36 37 20 38 39 40 22 41 42 19 43 16 44 45 15 46 47 48 18 49 50 51 52 17 53 14 54 55 12 56 57 58 11 59 60 13 61 62 5 63 4 64 65 66 67 68 10 69 70 9 71 72 8 73 74 7 75 76 6 77 2 78 79 80 1 81 82 3 83 84 0 85 26 24 27 ...
result:
ok
Test #10:
score: 90
Accepted
time: 1ms
memory: 3844kb
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 78 20 21 22 19 23 24 17 25 26 27 28 29 30 31 32 33 34 35 16 36 37 38 39 18 40 41 15 42 43 14 44 45 11 46 47 48 49 10 50 51 52 53 13 54 55 12 56 57 8 58 5 59 60 61 9 62 63 4 64 65 7 66 67 6 68 69 2 70 71 72 73 1 74 75 3 76 77 0 82 24 25 26 27 28 23 29 22 30 31 ...
result:
ok
Test #11:
score: 90
Accepted
time: 1ms
memory: 3780kb
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 67 14 15 13 16 17 18 19 20 21 22 23 24 25 26 11 27 28 10 29 30 12 31 32 9 33 8 34 35 36 37 38 39 5 40 41 42 43 44 4 45 46 7 47 48 49 50 6 51 52 53 54 2 55 56 1 57 58 59 60 3 61 62 0 63 64 65 66 60 19 18 20 21 15 22 13 23 24 25 17 26 27 16 28 29 12 30 31 32 33 ...
result:
ok
Test #12:
score: 90
Accepted
time: 0ms
memory: 3904kb
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 21 19 25 26 27 28 29 24 30 31 23 32 33 22 34 18 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 4 70 71 2 72 73 74 75 1 76 77 3 78 79 80 0 81 86 1 0 30 31 29 32 33...
result:
ok
Extra Test:
score: 0
Extra Test Passed