# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
681156 | QwertyPi | 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"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> construct_permutation(long long k){
vector<int> ans;
int l = 0, r = 1;
int mn0 = -1, mn1 = -1;
int b = 59;
while(~k & (1LL << b)) b--;
for(b--; b >= 0;){
if(b >= 1 && (k >> b - 1) % 2 && (k >> b) % 2 && mn0 != -1 && mn1 != -1){
ans.push_back(r++);
ans.push_back(r++);
ans[mn0]--; ans[mn1]--;
ans.push_back(l + 2); l--;
b -= 2;
}else{
if((k >> b) % 2){
ans.push_back(r++);
mn0 = mn1; mn1 = ans.size();
ans.push_back(l--);
}else{
ans.push_back(r++);
}
b--;
}
}
int mn = *min_element(ans.begin(), ans.end());
for(auto& i : ans) i -= mn;
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |