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>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
//#define lc (2*n)
//#define rc (2*n+1)
using namespace std;
ll mo = 1e9+7;
ll fp(ll x , ll y)
{
if(y==0)
return 1;
ll z = fp(x,y/2);
if(y&1)
return z*z%mo*x%mo;
else
return z*z%mo;
}
std::vector<int> construct_permutation(long long k)
{
vector<pll> v;
ll p = 0;
ll i = 0;
k--;
while(k>0)
{
ll x = fp(2,i-p);
if(k<x)
{
v.pb({p,i-1});
p=i;
continue;
}
if(k==x)
{
v.pb({p,i});
p=i;
k=0;
continue;
}
k-=x;
i++;
}
vector<int> ans(p+1,0);
ll x = 0;
for(int i = v.size()-1 ; i>=0 ; i--)
{
for(int j = v[i].F ; v[i].S >=j ; j++)
{
ans[j]=x;
x++;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |