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>
typedef long long ll;
#define pb push_back
using namespace std;
vector<int> construct_permutation(ll k)
{
vector<int>v, b;
while(k)
{
b.pb(k%4);
k/=4;
}
reverse(b.begin(), b.end());
if(b[0]==2) v.pb(0);
else if(b[0]==3) v={1, 0};
for(int i=1; i<(int)b.size(); i++)
{
if(b[i]==0)
{
v.pb(1e9);
v.pb(1e9+1);
}
else if(b[i]==1)
{
v.pb(1e9);
v.pb(1e9+1);
v.pb(-1);
}
else if(b[i]==2)
{
v.pb(1e9);
v.pb(-1);
v.pb(1e9+1);
}
else
{
int flag=0;
for(int u : v)
{
if(u==flag)
flag++;
}
if(flag>=2 or v.size()<2)
{
v.pb(1e9);
v.pb(-1);
v.pb(1e9+1);
v.pb(-2);
}
else
{
for(int j=0; j<(int)v.size(); j++)
v[j]<<=1;
v.pb(1e9);
v.pb(1e9+1);
v.pb(3);
}
}
vector<int>cur;
cur=v;
for(int j=0; j<(int)v.size(); j++)
{
int cnt=0;
for(int u : cur)
{
if(u<v[j]) cnt++;
}
v[j]=cnt;
}
}
return v;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |