# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
972133 | tamir1 | Permutation (APIO22_perm) | C++17 | 10 ms | 1116 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 <iostream>
#define ll long long
using namespace std;
vector<int> construct_permutation(long long k)
{
ll t=0,i,j,sum=0,idx=0;
k--;
vector<ll> v,u;
while(true){
if(t>k) break;
v.push_back(t);
t=t*2+1;
}
while(k>0){
for(i=v.size()-1;i>=0;i--){
if(v[i]<=k){
u.push_back(i);
k-=v[i];
break;
}
}
}
for(i=0;i<u.size();i++) sum+=u[i];
vector<int> ans(sum);
for(i=u.size()-1;i>=0;i--){
for(j=sum-u[i];j<sum;j++){
ans[j]=idx;
idx++;
}
sum-=u[i];
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |