# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
850015 | Andrey | Permutation (APIO22_perm) | C++17 | 2 ms | 760 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;
vector<int> construct_permutation(long long k) {
vector<int> ans(0);
long long br = 2,y = 0;
while(br <= k) {
ans.push_back(y);
y++;
br*=2;
}
k-=br/2;
for(long long i = y; i >= 0; i--) {
if((1LL << i) <= k) {
k-=(1LL << i);
ans.push_back(i);
for(int j = 0; j < ans.size()-1; j++) {
if(ans[j] >= i) {
ans[j]++;
}
}
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |