# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
821347 | Hanksburger | Permutation (APIO22_perm) | C++17 | 6 ms | 736 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)
{
if (k&1)
{
for (long long i=2, m=1; ; i*=2, m++)
{
if (i<k && i*2>k)
{
vector<int> res=construct_permutation(k-i+1);
for (long long j=0; j<res.size(); j++)
res[j]+=m;
for (long long j=0; j<m; j++)
res.push_back(j);
return res;
}
}
}
long long cnt=0;
while (k%2==0)
{
k/=2;
cnt++;
}
if (k==1)
{
vector<int> res;
for (long long i=0; i<cnt; i++)
res.push_back(i);
return res;
}
vector<int> res=construct_permutation(k);
int sz=res.size();
for (long long j=0; j<cnt; j++)
res.push_back(j+sz);
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |