제출 #596984

#제출 시각아이디문제언어결과실행 시간메모리
596984cfalas순열 (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include "perm.h" #include<bits/stdc++.h> using namespace std; typedef vector<int> vi; vi tr(long long k, int off){ vi a; int cnt=62; long long qq = (1LL<<off); if(k<qq) return vi(5000, 0); k-=qq; while(k>0 && cnt>off){ while(k>=(1LL<<cnt)-qq){ k-=((1LL<<cnt)-qq); a.push_back(cnt-off); } cnt--; } //cout<<k<<" left"<<endl; vi b; int p=off-1; for(auto v : a){ for(int i=p+v;i>p;i--){ b.push_back(i); } p = p+v; } for(int i=off-1;i>=0;i--) b.push_back(i); while(k) b.push_back(++p), k--; reverse(b.begin(), b.end()); return b; } vector<int> construct_permutation(long long k) { vi ans; int cnt=61; int aa=0; vi ins; while(cnt>=0){ if(k&(1LL<<cnt)){ ins.push_back(cnt); if(ans.size()==0){ for(int i=0;i<cnt;i++) ans.push_back(i); aa = cnt; } else{ ans.insert(ans.begin()+cnt, aa++); } } cnt--; } /* for(int i=0;i<20;i++){ vi b = tr(k, i); if(b.size()<ans.size() || ans.size()==0) ans = b; }*/ return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...