제출 #1020275

#제출 시각아이디문제언어결과실행 시간메모리
1020275TAhmed33순열 (APIO22_perm)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector <int> construct_permutation (ll k) { if (k == 1) { return {}; } if (k == 2) { return {0}; } if (k == 3) { return {1, 0}; } auto g = construct_permutation(k / 4); if (k % 4 == 0) { g.push_back(int(g.size())); g.push_back(int(g.size())); return g; } if (k % 4 == 1) { g.push_back(int(g.size())); g.push_back(int(g.size())); g.push_back(-1); for (auto &i : g) i++; return g; } if (k % 4 == 2) { g.push_back(int(g.size())); g.push_back(-1); g.push_back(int(g.size()) - 1); for (auto &i : g) i++; return g; } int pos0 = -1, pos1 = -1; for (int i = 0; i < int(g.size()); i++) { if (g[i] == 1) { pos1 = i; } if (g[i] == 0) { pos0 = i; } } if (pos1 > pos0) { g.push_back(int(g.size())); g.push_back(int(g.size())); for (auto &i : g) { if (i >= 2) i++; } g.push_back(2); return g; } g.push_back(int(g.size())); g.push_back(-1); g.push_back(int(g.size()) - 1); g.push_back(-2); for (auto &i : g) i += 2; return g; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...