# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
833196 | christinelynn | Permutation (APIO22_perm) | C++17 | 10 ms | 1364 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;
long long binpow(long long base, int exp) {
long long ret=1;
while(exp) {
if(exp&1) ret*=base;
base*=base;
exp>>=1;
}
return ret;
}
vector<int> construct_permutation(long long k) {
vector<int> ans; k--;
int mx=0;
while(k) {
int l=0, r=59, len=0;
while(l<=r) {
int mid=l+r>>1;
if(binpow(2, mid)-1<=k) len=mid, l=mid+1;
else r=mid-1;
}
mx-=len;
for(int i=mx+1; i<=mx+len; i++) ans.push_back(i);
k-=binpow(2, len)-1;
}
for(int &p : ans) p-=mx+1;
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |