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 <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define all(a) begin(a), end(a)
vector<int> construct_permutation(ll n)
{
vector<double> v; v.clear();
vector<int> A,D; A.clear(); D.clear();
while(n>0) D.pb(n%4),n/=4;
reverse(all(D));
int cnt = 0; int T=0, k=0, X = -1;
double t3 = 1.5;
for(auto u : D){
if(!cnt){
if(u==2) v.pb(0),T=1;
else if(u==3) v.pb(1), v.pb(0),T=2, k=1;
cnt = 1;
}
else{
if(u==0) v.pb(T++), v.pb(T++);
else if(u==1) v.pb(T++), v.pb(T++), v.pb(X--);
else if(u==2) v.pb(T++), v.pb(X--), v.pb(T++);
else if(k) v.pb(T++), v.pb(T++), v.pb(t3);
else v.pb(T++), v.pb(X--), v.pb(T++), v.pb(X--), t3=X+3.5, k=1;
}
}
//0 1 2 3 4 -1 5 -2
auto w = v; sort(all(w));
for(auto u : v) A.pb(lower_bound(all(w),u)-begin(w));
return A;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |