Submission #796680

#TimeUsernameProblemLanguageResultExecution timeMemory
796680Trisanu_DasPermutation (APIO22_perm)C++17
100 / 100
2 ms340 KiB
#include <bits/stdc++.h> using namespace std; vector<int> construct_permutation(long long k){ vector<int> ans; long long pow_2 = 1, exp_2 = 0, flag = 0, curr = 0; while(pow_2 * 2 <= k) pow_2 *= 2, exp_2++; for(int i = exp_2 - 1; i > -1; i--){ ans.push_back(curr++); if((k >> i) & 1){ if(i and (k >> (i-1) & 1) and flag > 1) ans.push_back(curr++), ans.insert(ans.begin() + 2, curr++), i--; else ans.insert(ans.begin(), curr++), flag++; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...