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>
#define ll long long
using namespace std;
const ll N=3e5+9,M=2e18+9,L=18,mod=1e9+7;
ll q=1,k;
ll pow(ll X,ll Y)
{
if(!Y)return 1;
if(Y&1)return X*pow(X,Y-1);
ll ret=pow(X,Y/2);
return ret*ret;
}
vector<ll> construct_permutation(ll k)
{
//cout<<"DONE\n";
ll g=k-1;
ll p[63],a[63],x=0,y;
vector<ll>v;
for(ll i=0;i<63;++i)p[i]=(1LL<<i)-1;
for(ll i=62;i;--i)
{
a[i]=0;
while(g>=p[i])g-=p[i],++a[i],x+=i;
}
for(ll i=62;i;--i)
while(a[i]--)
{
//cout<<p[i]<<' ';
y=x-i+1,x-=i;
for(ll j=0;j<i;++j)v.push_back(y-1),++y;
}
return v;
}
/*
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>q;
while(q--)
{
cin>>k;
vector<ll>v=construct_permutation(k);
cout<<v.size()<<'\n';
for(auto i:v)
cout<<i<<' ';
cout<<'\n';
}
}
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |