# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
733646 | Erkinoff_Mohammed | 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;
#define INF 2000000000
#define INFLL 3000000000000000000LL
#define ll long long
vector<int> construct_permutation(long long k){
vector<int>l;
while(k>0){
long long n=1;
int cnt=0;
while(n*2<=k){
n<<=1;
cnt++;
}
l.push_back(cnt);
k-=n;
}
vector<int>vec(l[0]+l.size()-1);
for(int i=0;i<l[0]+l.size()-1;i++){
vec[i]=i;
}
vector<int>en;
for(int i=l.size()-1;i>0;i--){
en.push_back(vec[l[i]]);
vec.erase(find(vec.begin(), vec.end(), vec[l[i]]));
}
for(int i=en.size()-1;i>-1;i--){
vec.push_back(en[i]);
}
return vec;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |