# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
584529 | rainboy | Permutation (APIO22_perm) | C++17 | 2 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "perm.h"
using namespace std;
typedef vector<int> vi;
vi construct_permutation(long long k) {
vi pp;
if (k == 2)
pp.push_back(0);
else {
int l = 0;
while (1LL << l + 1 <= k)
l++;
if ((k & 1LL << l - 1) != 0)
pp.push_back(1), pp.push_back(0), l -= 2;
else if ((k & 1LL << l - 2) == 0)
pp.push_back(2), pp.push_back(1), pp.push_back(0), l -= 3;
else
pp.push_back(3), pp.push_back(2), pp.push_back(1), pp.push_back(0), l -= 3;
int n = pp.size();
while (l > 0) {
int b = k >> l - 1 & 3;
if (b == 0)
pp.push_back(n++), pp.push_back(n++);
else if (b == 1) {
pp.push_back(n++), pp.push_back(n++);
for (int i = 0; i < n; i++)
pp[i]++;
pp.push_back(0), n++;
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |