QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#414362 | #4252. Permutation | james1BadCreeper | 10 | 1ms | 4024kb | C++14 | 1.0kb | 2024-05-18 21:58:46 | 2024-05-18 21:58:48 |
Judging History
answer
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int INF = 1e9;
vector<int> construct_permutation(i64 k) {
int len = 0;
// 1 2 4 8 16 32 64 128 256 512
while (k >= (1ll << len)) ++len;
--len;
k -= 1 << len;
vector<int> a(len + 5, -1), ans, b;
int mn = -1, se = -1;
for (int i = len - 1; i >= 0; --i)
if (k >> i & 1) {
if (i && (k >> i - 1 & 1) && mn != -1 && se != -1) {
--a[mn];
a[i - 1] = a[se];
--a[se];
--i;
} else if (mn != -1) a[i] = a[mn] - 1, se = mn, mn = i;
else a[i] = INF - 1, mn = i;
}
for (int i = 0; i < len; ++i) {
if (a[i] != -1) ans.push_back(a[i]);
ans.push_back(2 * INF - i);
}
reverse(ans.begin(), ans.end()); b = ans; sort(b.begin(), b.end());
for (int &i : ans)
i = lower_bound(b.begin(), b.end(), i) - b.begin();
return ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 1ms
memory: 4024kb
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: 0
Wrong Answer
Test #2:
score: 90
Accepted
time: 1ms
memory: 3792kb
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: 3776kb
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: 0
Wrong Answer
time: 1ms
memory: 3788kb
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 15 31 1 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 0 61 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:
wrong answer