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;
#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define cbug if(DEBUG) cout
#define setp(x) cout<<fixed<<setprecision(x)
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
vi makePerm(vi a)
{
int n = sz(a);
vi dis(all(a));
sort(all(dis));
forn(i,0,n)
{
a[i] = lower_bound(all(dis), a[i]) - dis.begin();
}
return a;
}
std::vector<int> construct_permutation(long long n)
{
ll L=0, R=0;
vi ans{0};
int i = 62;
while(!((1LL << i) & n)) i--;
i--;
while (i >= 0)
{
if ((1LL << i) & n)
{
L--;
ans.pb(L);
}
if (i != 0)
{
R++;
ans.pb(R);
}
i--;
}
return makePerm(ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |