Submission #912366

#TimeUsernameProblemLanguageResultExecution timeMemory
912366huyngoPermutation (APIO22_perm)C++17
0 / 100
183 ms262144 KiB
#include "perm.h" std::vector<int> construct_permutation(long long k) { std::vector<int> a; long long l = 0, r = 0, dd = 0; auto work = [&](auto self, long long x) -> void { if (x & 1) { a.push_back(--l); dd = l; self(self, x - 1); } else { a.push_back(++r); self(self, x >> 1); } }; work(work, k); for (auto& x : a) x -= (dd - 1); return a; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...