Submission #931076

#TimeUsernameProblemLanguageResultExecution timeMemory
931076sleepntsheepPermutation (APIO22_perm)C++17
91.33 / 100
2 ms348 KiB
#include "perm.h" #include <stdio.h> #include <algorithm> std::vector<int> construct_permutation(long long k) { std::vector<int> v; int msb = 63 - __builtin_clzll(k); for (int i = 1; i <= msb; ++i) v.push_back(i*2); k &= ~(1ll << msb); for (int i = msb - 1; i >= 0; --i) { if (k & (1ll << i)) { v.push_back(i*2+1); } } auto w = v; std::sort(w.begin(), w.end()); for (int &x : v) x = std::lower_bound(w.begin(), w.end(), x) - w.begin(); //for (int x : v) printf("%d ", x); return v; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...