Submission #866705

#TimeUsernameProblemLanguageResultExecution timeMemory
866705Dec0DeddPermutation (APIO22_perm)C++17
100 / 100
2 ms352 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 vector<int>{0}; for (int p : {2, 3, 5, 7, 11, 13, 17, 19, 23, 29}) { if (k%p == 0 && k > p) { vector<int> lf=construct_permutation(k/p), r=construct_permutation(p); for (auto &x : r) x+=lf.size(); lf.insert(lf.end(), r.begin(), r.end()); return lf; } } vector<int> a=construct_permutation(k/2); a.push_back(a.size()); if (k&1) a.insert(a.begin(), a.size()); return a; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...