Submission #725274

#TimeUsernameProblemLanguageResultExecution timeMemory
725274SanguineChameleonPermutation (APIO22_perm)C++17
100 / 100
2 ms384 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; vector<int> construct_permutation(long long k) { if (k == 1) { return {}; } vector<int> nums = {2, 3, 5, 7}; for (auto p: nums) { if (k % p == 0 && k > p) { vector<int> res1 = construct_permutation(k / p); int n = res1.size(); vector<int> res2 = construct_permutation(p); for (auto &x: res2) { x += n; } res1.insert(res1.end(), res2.begin(), res2.end()); return res1; } } vector<int> res = construct_permutation(k / 2); int n = res.size(); res.push_back(n); if (k % 2 == 1) { for (auto &x: res) { x++; } res.push_back(0); } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...