# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
704729 | 2023-03-02T20:57:36 Z | beaconmc | 화성 (APIO22_mars) | C++17 | 0 ms | 0 KB |
#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; }