# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
704728 | beaconmc | Mars (APIO22_mars) | 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.
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#include "perm.h"
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
using namespace std;
vector<int> construct_permutation(long long k)
{
ll imp = k;
vector<ll> ops;
deque<ll> sus;
while (k>1){
if (k%3==0){
ops.push_back(3);
k/=3;
continue;
}
if (k%2==0){
ops.push_back(2);
k /= 2;
}else{
ops.push_back(1);
k -= 1;
}
}
ll cur = 0;
reverse(ops.begin(), ops.end());
for (auto&i : ops){
if (i==1) sus.push_front(cur);
else if (i==2) sus.push_back(cur);
else if (i==3) {
sus.push_back(cur+1);
sus.push_back(cur);
cur++;
}
cur++;
}
vector<int> ans;
for (auto&i : sus) ans.push_back(i);
return ans;
}
int main(){
vector<int> a = construct_permutation(28);
for (auto&i : a){
cout << i << endl;
}
}