Submission #776511

#TimeUsernameProblemLanguageResultExecution timeMemory
776511AlanPermutation (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include <bits/stdc++.h> #include "perm.h" using namespace std; using ll = long long; vector<int> construct_permutation(ll k) { vector<int> ans; int l = 0, r = 150; vector<int> bin; for (int i = 0; i < 60; i++) bin.push_back(!!((1LL<<i) & k)); while (!bin.back()) bin.pop_back(); int sz = bin.size(); for (int i = 0; i+1 < sz; i++) { if (bin[i] && i+2 < sz && bin[i+1]) { ans.push_back(r-1); ans.push_back(r); r -= 2; ans.push_back(l++); i++; } else if (bin[i]) ans.push_back(r--); ans.push_back(l++); } for (auto& x : ans) if (x >= l) x = x - (r-l+1); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...