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