# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
911300 | 2024-01-18T18:02:02 Z | hjroh0315 | Permutation (APIO22_perm) | C++17 | 0 ms | 0 KB |
#include"perms.h" #include<bits/stdc++.h> using namespace std; std::vector<int>construct_permutation(long long k) { vector<int>ans; auto f=k;int last=-1; for(int i=0;i<62;i++) { if(f>0) { if(f&1)f--; if(f>0)ans.push_back(i); last=i; f>>=1; } } last--; while(last>=0) { if(k>>last&1) { for(int i=0;i<size(ans);i++) { if(ans[i]>=last)ans[i]++; } ans.push_back(last); } last--; } return ans; }