Submission #730760

#TimeUsernameProblemLanguageResultExecution timeMemory
730760alextodoranPermutation (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
/** _ _ __ _ _ _ _ _ _ |a ||t ||o d | |o | | __ _| | _ | __| _ | | __ |/_ | __ /__\ / _\| **/ #include <bits/stdc++.h> using namespace std; typedef long long ll; vector <int> construct_permutation (ll k) { int bits = 63 - __builtin_clzll(k); int len = bits + __builtin_popcountll(k) - 1; if (true) { vector <int> p; int l = 0, r = len - 1; for (int e = 0; e < bits; e++) { if ((k >> e) & 1) { p.push_back(r--); } p.push_back(l++); } return p; } else { vector <int> p = construct_permutation(k / 3); int len = (int) p.size(); vector <int> q; for (int i = len + k % 3 + 1; i > len + 1; i--) { q.push_back(i); } for (int x : p) { q.push_back(x); } q.push_back(len + 1); q.push_back(len); return q; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...