제출 #579571

#제출 시각아이디문제언어결과실행 시간메모리
579571SeDunion순열 (APIO22_perm)C++17
100 / 100
4 ms372 KiB
#include "perm.h" #include <iostream> #include <vector> using namespace std; using vi = vector<int>; using ll = long long; vi solve(ll k) { if (k == 1) return {}; if (k == 2) return {0}; for (int i : {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}) { if (k % i == 0 && k > i) { vi l = solve(i); vi r = solve(k/i); for (int &o : r) o += l.size(); l.insert(l.end(), r.begin(), r.end()); return l; } } vi a = solve(k >> 1ll); a.emplace_back(a.size()); a.insert(a.begin(), a.size()); return a; } vi construct_permutation(ll k) { return solve(k); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...