# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
702141 | ld_minh4354 | 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"
using namespace std;
vector<int> construct_permutation(long long k)
{
long long a[5005],i,j,cur_val,pos,cur_k,n;
cur_k=k;
n=1;a[1]=0;cur_val=2;
while (cur_val*2<=k)
{
n++;a[n]=n-1;
cur_val*=2;
}
cur_k -= cur_val;
while (cur_k > 0)
{
cur_val=1;pos=1;
while (cur_val*2 <= cur_k)
{
pos++;cur_val*=2;
}
for (i=n+1;i>pos;i--) a[i]=a[i-1];
n++;a[pos]=n-1;
cur_k -= cur_val;
}
vector<int> ans;
for (i=1;i<n+1;i++) ans.push_back(a[i]);
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |