# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1130515 | ooscode | Permutation (APIO22_perm) | C++17 | 0 ms | 0 KiB |
int[] construct_permutation(int64 k) {
vector<pair<pair<int , int> , int>> vec;
for(int i = 60 ; ~i ; i++) if((1ll << i) & k) {
if(vec.size()) vec.pb({{i + 1 , 0} , vec.size()});
else
for(int j = 1 ; j <= i ; j++)
vec.pb({{j , 1} , vec.size()});
}
sort(all(vec));
int a[vec.size()];
for(int i = 0 ; i < vec.size() ; i++)
a[vec[i].S] = i;
return a;
}