This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///~~~LOTA~~~///
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
#define N 60
ll pwr[N];
vector<int> construct_permutation(ll n){
pwr[0]=1;
for(ll i=1;i<N;i++)
pwr[i]=pwr[i-1]*2LL;
ll m=log2(n);
vector<int> u,v;
for(int i=0;i<m;i++)
v.append(i);
n-=pwr[m];
for(int i=m-1;i>0;i--){
if(n<pwr[i]) continue;
n-=pwr[i];
u.append(v[m-i]);
for(int j=m-i;j<m;j++)
v[j]++;
}
if(n) u.append(v.back()+1);
reverse(all(u));
for(auto& i:v)
u.append(i);
return u;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |