# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
710581 | Astrayt | Permutation (APIO22_perm) | C++17 | 8 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;
typedef long long ll;
#define pb push_back
vector<int> construct_permutation(ll k){
vector<int> d, ans;
ll tmp = k;
while(tmp){
d.pb(tmp & 3ll);
tmp >>= 2;
}
if(d.back() == 2) ans = {0};
if(d.back() == 3) ans = {1, 0};
d.pop_back();
while(d.size()){
int x = d.back(), n = ans.size(); d.pop_back();
if(x == 0){
ans.pb(n), ans.pb(n + 1);
}else if(x == 1){
ans.pb(n), ans.pb(n + 1), ans.pb(-1);
}else if(x == 2){
ans.pb(n), ans.pb(-1), ans.pb(n + 1);
}else if(x == 3){
bool flag = 0, flag2 = 0;
for(auto x:ans){
flag |= (x == 1);
if(flag && x == 0) flag2 = 1;
}
if(flag2){
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |