# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
979047 | sunnat | Permutation (APIO22_perm) | C++17 | 1 ms | 348 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 <iostream>
#include <vector>
using namespace std;
int count_zeros(long long k){
return k ? ((k&1)^1) + count_zeros(k>>1) : 0;
}
vector<int> construct_permutation(long long k){
--k;
vector<int> a;
while(count_zeros(k - ((1LL<<a.size())-1)) > a.size())
a.push_back(a.size());
k -= (1LL<<a.size()) - 1;
for(int i = 0; k > 0; ++ i){
if((k>>i)&1){
a.insert(a.begin()+i, a.size());
k -= 1ll<<i;
}
}
return a;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |