# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1160553 | Aviansh | Permutation (APIO22_perm) | C++20 | 1 ms | 328 KiB |
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> construct_permutation(long long k)
{
vector<int>ans;
vector<int>pows;
int sum = 0;
for(int i = 63;i>=0;i--){
if(k&(1LL<<i)){
pows.push_back(i);
sum+=i;
}
}
//pows should be rev sorted
for(int i = 0;i<pows.size();i++){
if(pows[i]==0)
break;
if(i==0){
for(int j = 0;j<pows[i];j++){
ans.push_back(j);
}
}
else{
for(int j = pows[i];j<ans.size();j++){
ans[j]++;
}
ans.push_back(pows[i]);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |