# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
911398 | asdasdqwer | Permutation (APIO22_perm) | C++17 | 0 ms | 0 KiB |
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>
using namespace std;
#define int int64_t
vector<int32_t> construct_permutation(int64_t x) {
if (x==2) {
return {1};
}
x--;
vector<int32_t> out;
__uint128_t ONE=1;
int cnt=0;
vector<int> v;
for (int i=65;i>0;i--) {
while (x >= (((ONE<<i)-1))) {
v.push_back(i);
x -= ((ONE<<i)-1);
}
}
for (int i=1;i<=v.size();i++) {
int start=(1e9-1e5)/i;
for (int j=0;j<v[i-1];j++) {
out.push_back(start+j);
}
}
vector<int32_t> al=out;
sort(al.begin(),al.end());
map<int,int> mp;
for (int i=0;i<al.size();i++) {
mp[al[i]]=i;
}
for (int32_t &x:out) {
x = mp[x];
}
return out;
}