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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll K;
std::vector<int> construct_permutation(long long _k)
{
K=_k;
vector<int> ans, V;
ll t=K;
int cnt=0;
for(int i=0; i<30 && t; i++)
{
if(t<4)
{
cnt+=t-1;
for(int j=1; j<t; j++) ans.push_back(--cnt);
}
else if(t%4)
{
cnt+=4;
for(int j=t%4-1; j<3; j++) ans.push_back(--cnt);
V.push_back(--cnt);
for(int j=0; j<t%4-1; j++) ans.push_back(--cnt);
cnt+=4;
}
else
{
cnt+=3;
ans.push_back(--cnt);
ans.push_back(--cnt);
ans.push_back(--cnt);
cnt+=3;
}
t/=4;
}
while(!V.empty()) ans.push_back(V.back()), V.pop_back();
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |