Submission #745267

#TimeUsernameProblemLanguageResultExecution timeMemory
745267speedyArdaPermutation (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include "perm.h" #include "bits/stdc++.h" using namespace std; vector<int> construct_permutation(long long k) { long long beg = __lg(k); vector<int> ans; for(int i = 0; i < beg; i++) ans.push_back(i); long long rem = k - (1LL << beg); for(long long i = beg - 1; i >= 0; i--) { if(rem & (1LL << i)) { rem -= (1LL << i); ans.insert(ans.begin() + i, beg++); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...