This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |