Submission #956929

#TimeUsernameProblemLanguageResultExecution timeMemory
956929LaviniaTornaghiPermutation (APIO22_perm)C++17
91.33 / 100
2 ms600 KiB
#include <bits/stdc++.h> #include "perm.h" using namespace std; vector<int> construct_permutation(long long k) { int last_digit = 63 - __builtin_clzll(k); int extras = __builtin_popcountll(k); vector<int> ans; int lo = extras - 2; int hi = extras - 1; for (int b = last_digit - 1; b >= 0; b--) { ans.push_back(hi++); if ((k >> b) & 1) ans.push_back(lo--); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...