제출 #978302

#제출 시각아이디문제언어결과실행 시간메모리
978302Nexus순열 (APIO22_perm)C++17
0 / 100
0 ms348 KiB
#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]=pow(2,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); for(auto i:v) cout<<i<<' '; cout<<'\n'; } } */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...