# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
572776 | benson1029 | Permutation (APIO22_perm) | C++17 | 2 ms | 368 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"
#include<bits/stdc++.h>
using namespace std;
std::vector<int> construct_permutation(long long k)
{
if(k==2) return {0};
else if(k==3) return {1, 0};
else if(k==4) return {0, 1};
else if(k==5) return {2, 0, 1};
else if(k==6) return {0, 2, 1};
else if(k==7) return {2, 1, 3, 0};
else {
vector<int> p = construct_permutation(k/4);
if(k%4 == 0) { // *4
p.push_back(p.size());
p.push_back(p.size());
return p;
} else if(k%4==1) { // *4+1
p.push_back(p.size());
p.push_back(p.size());
p.push_back(0);
for(int i=p.size()-2; i>=0; i--) p[i]++;
return p;
} else if(k%4==2) { // *4+2
for(int i=0; i<p.size(); i++) p[i]++;
int t = p.size();
p.push_back(t+1);
p.push_back(0);
p.push_back(t+2);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |