Submission #911871

#TimeUsernameProblemLanguageResultExecution timeMemory
911871nullchillyPermutation (APIO22_perm)C++17
91.33 / 100
2 ms600 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; std::vector<int> construct_permutation(long long k) { int m = __lg(k) + 1; vector<int> zero(m + 1); int pad = 0; for (int j = 0; j <= m; j++) { if (k & (1ll << j)) { zero[m - j - 1] = ++pad; } } vector<int> ans; for (int i = 1; i < m; i++) { ans.push_back(i + pad - 2); if (zero[i]) ans.push_back(zero[i] - 1); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...