# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
634774 | MinaRagy06 | 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 <bits/stdc++.h>
#include "perm.h"
using namespace std;
vector<int> construct_permutation(long long m)
{
long long k = m;
if (k == 2) return {0};
if (k == 3) return {1, 0};
stack<int> ops; //0 -> *2, 1 -> +1, 2 -> +2, 3 -> +3
while (((k>>4)&1) || k >= (1<<5)-1)
{
if ((k&3) == 3) ops.push(3), ops.push(0), ops.push(0), k>>=2;
else if ((k&1) == 1) ops.push(1), ops.push(0), ops.push(0), k>>=2;
else ops.push(0), k>>=1;
}
if (k == 0b0100) ops.push(1);
if (k == 0b0101) ops.push(2);
if (k == 0b0110) ops.push(3);
if (k == 0b0111) ops.push(3), ops.push(1);
if (k == 0b1000) ops.push(0), ops.push(1);
if (k == 0b1001) ops.push(1), ops.push(0), ops.push(1);
if (k == 0b1010) ops.push(0), ops.push(2);
if (k == 0b1011) ops.push(3), ops.push(0), ops.push(1);
if (k == 0b1100) ops.push(0), ops.push(0);
if (k == 0b1101) ops.push(1), ops.push(0), ops.push(0);
if (k == 0b1110) ops.push(0), ops.push(1), ops.push(0);
if (k == 0b1111) ops.push(3), ops.push(0), ops.push(0);
// long long sum = 3;
// while (ops.size()) sum = sum*(ops.top() == 0? 2 : 1) + ops.top(), ops.pop();
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |