QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#290540 | #4252. Permutation | MoRanSky | 100 ✓ | 1ms | 4036kb | C++23 | 1.1kb | 2023-12-25 05:40:45 | 2023-12-25 05:40:46 |
Judging History
answer
// Skyqwq
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
template <typename T> bool chkMax(T &x, T y) { return (y > x) ? x = y, 1 : 0; }
template <typename T> bool chkMin(T &x, T y) { return (y < x) ? x = y, 1 : 0; }
#include "perm.h"
namespace {
const int N = 100;
int a[N];
}
std::vector<int> construct_permutation(long long k) {
bool op = 0;
int h = 0;
for (int i = 0; i < 60; i++)
if (k >> i & 1) h = i;
int n = 0;
for (int i = h - 1; i >= 0; i--) {
++n;
a[n] = n;
int x = -1, y = -1;
for (int j = 1; j <= n; j++) {
if (a[j] == 1) x = j;
if (a[j] == 2) y = j;
}
if (i > 0 && (k >> i & 1) && (k >> (i - 1) & 1) && x != -1 && y != -1 && y < x) {
++n;
a[n] = n;
a[++n] = 3;
for (int j = 1; j < n; j++)
if (a[j] >= 3) a[j]++;
i = i - 1;
continue;
}
if (k >> i & 1) {
++n;
a[n] = 1;
for (int j = 1; j < n; j++) a[j]++;
}
}
vector<int> res;
for (int i = 1; i <= n; i++) res.pb(a[i] - 1);
return res;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 3992kb
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: 1ms
memory: 4000kb
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 20 3 6 2 7 8 5 9 10 4 11 12 13 14 15 16 17 1 18 19 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 3 ...
result:
ok
Test #3:
score: 90
Accepted
time: 0ms
memory: 3728kb
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 2 1 17 18 16 19 20 15 21 22 14 23 24 13 25 26 12 27 28 11 29 30 10 31 32 9 33 34 8 35 36 7 37 38 6 39 40 5 41 42 4 43 44 3 45 0 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 2...
result:
ok
Test #4:
score: 90
Accepted
time: 1ms
memory: 3724kb
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 2 1 31 32 30 33 34 29 35 36 28 37 38 27 39 40 26 41 42 25 43 44 24 45 46 23 47 48 22 49 50 21 51 52 20 53 54 19 55 56 18 57 58 17 59 60 16 61 62 15 63 64 14 65 66 13 67 68 12 69 70 11 71 72 10 73 74 9 75 76 8 77 78 7 79 80 6 81 82 5 83 84 4 85 86 3 87 0 86 ...
result:
ok
Test #5:
score: 90
Accepted
time: 1ms
memory: 3768kb
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 52 13 15 16 12 17 18 14 19 20 21 10 22 23 9 24 25 26 11 27 28 29 8 30 31 5 32 33 2 34 35 36 37 7 38 39 6 40 41 42 43 1 44 45 46 4 47 48 3 49 50 51 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 40...
result:
ok
Test #6:
score: 90
Accepted
time: 1ms
memory: 3824kb
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 59 8 12 13 5 14 15 16 11 17 18 19 20 21 22 10 23 24 25 26 27 28 29 9 30 31 32 33 34 3 35 36 37 7 38 39 40 41 6 42 43 2 44 45 46 4 47 48 49 50 51 52 53 54 55 1 56 57 58 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 38 ...
result:
ok
Test #7:
score: 90
Accepted
time: 1ms
memory: 3904kb
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 71 16 19 20 21 15 22 23 24 18 25 26 27 17 28 29 30 14 31 32 33 34 35 10 36 37 38 9 39 40 41 13 42 43 12 44 45 46 11 47 8 48 49 50 51 52 5 53 54 4 55 56 57 58 7 59 60 6 61 2 62 63 1 64 65 66 67 3 68 69 70 0 81 22 23 19 24 18 25 26 27 28 29 21 30 31 32 20 33 34 ...
result:
ok
Test #8:
score: 90
Accepted
time: 1ms
memory: 4012kb
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: 3744kb
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 82 21 18 24 25 26 23 27 28 22 29 30 31 32 33 34 15 35 36 37 20 38 39 40 19 41 42 14 43 44 45 17 46 47 48 49 16 50 12 51 52 5 53 54 55 56 13 57 3 58 59 60 11 61 62 63 64 65 10 66 67 9 68 69 8 70 71 7 72 73 6 74 2 75 76 77 78 4 79 1 80 81 0 81 20 17 23 24 25 22 ...
result:
ok
Test #10:
score: 90
Accepted
time: 1ms
memory: 4004kb
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: 3808kb
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 57 13 10 17 18 19 16 20 21 22 15 23 24 14 25 26 9 27 28 29 30 12 31 3...
result:
ok
Test #12:
score: 90
Accepted
time: 1ms
memory: 4036kb
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 3 70 71 2 72 73 74 75 76 4 77 1 78 79 80 0 81 86 1 0 30 31 29 32 33...
result:
ok
Extra Test:
score: 0
Extra Test Passed