#include <bits/stdc++.h>
#include "perm.h"
using namespace std;
vector<int> construct_permutation(long long x) {
vector<int> cur;
int a = 1;
cur.emplace_back(a);
while ((1LL << (a + 1)) <= x) {
a++;
cur.emplace_back(a);
}
vector<int> res;
int sz = (int) cur.size();
for (int i = 0; i < sz; i++) {
res.emplace_back(cur[i]);
if ((x >> (sz - i - 1) & 1)) {
res.emplace_back(1);
}
}
int idx = 0;
set<int> s;
for (int i = (int) res.size() - 1; i >= 0; i--) {
if (res[i] == 1) {
res[i] = idx;
s.insert(i);
idx++;
}
}
for (int i = 0; i < (int) res.size(); i++) {
if (!s.count(i)) {
res[i] = idx;
idx++;
}
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Partially correct |
2 ms |
344 KB |
Partially correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Partially correct |
2 ms |
348 KB |
Partially correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Partially correct |
2 ms |
348 KB |
Partially correct |
11 |
Partially correct |
2 ms |
344 KB |
Partially correct |
12 |
Partially correct |
2 ms |
348 KB |
Partially correct |
13 |
Partially correct |
2 ms |
344 KB |
Partially correct |