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 "perm.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using i64 = long long;
#define ln "\n"
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a; i<=b; ++i)
const int mxN = 1e6 + 5;
int n;
vector<int> construct_permutation(long long k) {
vector<int> ans;
int l = 0, r = 0;
auto work = [&](auto self, ll x) -> void {
if (x == 1) return;
if (x & 1) {
self(self, x - 1);
ans.push_back(--l);
}
else {
self(self, x >> 1);
ans.push_back(++r);
}
};
work(work, k);
vector<int> s = ans;
sort(all(s));
s.erase(unique(all(s)), s.end());
for (int& i : ans)
i = lower_bound(all(s), i) - s.begin();
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |