제출 #1118747

#제출 시각아이디문제언어결과실행 시간메모리
1118747Username_taken12순열 (APIO22_perm)C++17
91.33 / 100
2 ms596 KiB
#include <bits/stdc++.h> #include "perm.h" using namespace std; vector<int> construct_permutation(long long k) { //int cnt = std::popcount((unsigned long long) k); int cnt=0; int size =0; long long t=k; while(t>0){ size++; if(t%2==1) cnt++; t/=2; } //size--; //cout<<size<<" "<<cnt<<endl; cnt--; int len = size-1+cnt; int h=len-1; int a =0; vector<int> out; while(k>1){ if(k%2==1&&k!=1) out.push_back(h--); out.push_back(a++); k/=2; } return out; } /*int main() { long long k; cin>>k; vector<int> ans = construct_permutation(k); for(int i=0; i<ans.size(); i++) cout<<ans[i]<<" "; cout<<endl; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...