Submission #908581

#TimeUsernameProblemLanguageResultExecution timeMemory
908581vjudge1Permutation (APIO22_perm)C++17
100 / 100
2 ms604 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; vi construct_permutation(ll k) { if(k == 1) return {}; if(k == 2) return vi{0}; for(int i: {2, 3, 5, 7, 11, 13, 17, 19, 23, 29}) { if(k % i == 0 && k > i) { vi l = construct_permutation(k / i); vi r = construct_permutation(i); for(auto& x: r) x += l.size(); l.insert(l.end(), r.begin(), r.end()); return l; } } vi 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...