Submission #578429

#TimeUsernameProblemLanguageResultExecution timeMemory
5784291zaid1Permutation (APIO22_perm)C++17
91.33 / 100
3 ms340 KiB
#include "perm.h" #include "bits/stdc++.h" using namespace std; vector<int> construct_permutation(long long k) { vector<int> ans; int mx = 1000, mn = -1000; vector<int> steps; while (k != 1) { if (k%2) ans.push_back(mn++); ans.push_back(mx--); k /= 2; } reverse(ans.begin(), ans.end()); map<int, int> fr; vector<int> tmp = ans; int ind = 0; sort(tmp.begin(), tmp.end()); for (int i:tmp) { fr[i] = ind++; } for (int&i:ans) i = fr[i]; return ans; } /* 1 2 4 5 10 11 22 23 {} {0 1 -1 2 -2 3 -3} {3 4 2 5 1 6 0} {} */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...