QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#414355 | #4252. Permutation | james1BadCreeper | 0 | 1ms | 3836kb | C++14 | 884b | 2024-05-18 21:50:35 | 2024-05-18 21:50:35 |
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;
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(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;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3836kb
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 4 2 1 3 0 2 0 1 5 2 1 3 4 0 5 2 1 3 0 4 6 3 2 4 1 5 0 3 0 1 2 6 2 1 3 4 5 0 6 2 1 3 4 0 5 7 3 2 4 5 1 6 0 6 2 1 3 0 4 5 7 3 2 4 1 5 6 0 7 3 2 4 1 5 0 6 7 3 1 4 0 5 6 2 4 0 1 2 3 7 2 1 3 4 5 6 0 7 2 1 3 4 5 0 6 8 3 2 4 5 6 1 7 0 7 2 1 3 4 0 5 6 8 3 2 4 5 1 ...
result:
wrong answer
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 1ms
memory: 3776kb
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 22 6 3 7 8 9 2 10 11 5 12 13 14 15 16 17 4 18 1 19 20 21 0 24 7 5 8 9 2 10 11 12 13 6 14 1 15 16 17 4 18 19 20 21 3 22 23 0 22 6 3 7 8 2 9 10 5 11 12 4 13 14 15 16 17 18 19 1 20 21 0 21 6 4 7 1 8 9 10 11 12 5 13 14 15 0 16 17 18 3 19 20 2 17 3 1 4 0 5 6 2 7 8 ...
result:
wrong answer