# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
705259 | veehz | Permutation (APIO22_perm) | C++17 | 2 ms | 340 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 "perm.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> construct_permutation(ll k){
vector<int> pow;
for(int i=0;i<62;i++){
if(k&(1LL<<i)){
pow.push_back(i);
}
}
// cout << "POW" << endl;
// for(int i=0;i<pow.size();i++){
// cout << pow[i] << " ";
// }
// cout << endl;
vector<int> ans;
int nxtIdx = 0;
int nxtNum = pow.back() + pow.size() - 2;
for(int i=0;i<pow.back();i++){
if(nxtIdx < pow.size() && i == pow[nxtIdx]){
ans.push_back(nxtNum);
nxtNum--;
nxtIdx++;
}
ans.push_back(i);
}
// print
// for(int i=0;i<ans.size();i++){
// cout << ans[i] << " ";
// }
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |