# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
915208 | a_l_i_r_e_z_a | Permutation (APIO22_perm) | C++17 | 0 ms | 0 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.
// In the name of God
// Hope is last to die
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define pb push_back
#define S second
#define F first
#define mp make_pair
#define smax(x, y) (x) = max((x), (y))
#define smin(x, y) (x) = min((x), (y))
#define all(x) (x).begin(), (x).end()
#define len(x) ((int)(x).size())
const int maxn = 200 + 5;
const int inf = 1e9 + 7;
vector<int> construct_permutation(ll k){
vector<int> vec;
if(k == 1) return vec;
if(k == 2){
vec.pb(0);
return vec;
}
if(k == 3){
vec.pb(1);
vec.pb(0);
return vec;
}
ll r = k % 4;
vec = construct_permutation(k / 4);
int n = len(vec);
if(r == 0){
vec.pb(n);
vec.pb(n + 1);
}
else if(r == 1){
for(auto &u: vec) u++;
vec.pb(n + 1);
vec.pb(n + 2);
vec.pb(0);
}
else if(r == 2){
for(auto &u: vec) u++;
vec.pb(n + 1);
vec.pb(0);
vec.pb(n + 2);
}
else{
bool flag;
for(auto u: vec) if(u < 2){
flag = u;
break;
}
if(flag){
for(auto &u: vec) if(u > 1) u++;
vec.pb(n + 1);
vec.pb(n + 2);
vec.pb(2);
}
else{
for(auto &u: vec) u += 2;
vec.pb(n + 2);
vec.pb(1);
vec.pb(n + 3);
vec.pb(0);
}
}
return res;
}
// int32_t main()
// {
// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// return 0;
// }