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>
#ifndef SKY
#include "perm.h"
#endif // SKY
using namespace std;
#define N 1010
#define ll long long
#define fs first
#define sc second
#define ii pair<ll,int>
#define pb push_back
vector<int> construct_permutation(long long k)
{
int u=63-__builtin_clzll(k),n=0;
//cout<<k<<" "<<u<<endl;
k-=(1ll<<u);
vector<int>lis[N];
for(int i=1;i<=u;i++)
lis[i].pb(n++);
while(k>0)
{
int cc=63-__builtin_clzll(k);
k-=(1ll<<cc);
lis[cc].pb(n++);
}
vector<int>kq;
for(int i=0;i<=60;i++)
for(auto u:lis[i])
kq.pb(u);
return kq;
}
#ifdef SKY
int main()
{
freopen("A.inp","r",stdin);
freopen("A.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
ll k;
cin>>k;
vector<int>kq=construct_permutation(k);
for(auto u:kq)cout<<u<<" ";
return 0;
}
#endif
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |