제출 #1160553

#제출 시각아이디문제언어결과실행 시간메모리
1160553AvianshPermutation (APIO22_perm)C++20
91.33 / 100
1 ms328 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; vector<int> construct_permutation(long long k) { vector<int>ans; vector<int>pows; int sum = 0; for(int i = 63;i>=0;i--){ if(k&(1LL<<i)){ pows.push_back(i); sum+=i; } } //pows should be rev sorted for(int i = 0;i<pows.size();i++){ if(pows[i]==0) break; if(i==0){ for(int j = 0;j<pows[i];j++){ ans.push_back(j); } } else{ for(int j = pows[i];j<ans.size();j++){ ans[j]++; } ans.push_back(pows[i]); } } if(pows[pows.size()-1]==0){ ans.insert(ans.begin(),ans.size()); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...