# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
645651 | czhang2718 | Permutation (APIO22_perm) | C++17 | 3 ms | 356 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"
using namespace std;
// #include "perm.h"
std::vector<int> construct_permutation(long long S)
{
vector<int> v;
bool emp=1;
int t=0;
for(int i=30; i>=0; i--){
int d=(S/(1LL<<(2*i)))%4;
if(emp){
if(!d) continue;
if(d==1) {}
if(d==2) v={0};
if(d==3) v={1,0};
emp=0;
continue;
}
int mx=(v.size()?*max_element(v.begin(), v.end()):0);
int mn=(v.size()?*min_element(v.begin(), v.end()):0);
if(d==0){
v.push_back(mx+1);
v.push_back(mx+2);
}
if(d==1){
v.push_back(mx+1);
v.push_back(mx+2);
v.push_back(mn-1);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |