제출 #638463

#제출 시각아이디문제언어결과실행 시간메모리
638463TranGiaHuy1508순열 (APIO22_perm)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; namespace { vector<int> primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}; deque<int> q; int lim; void mult(int x){ for (int i = lim + x - 2; i >= lim; i--){ q.push_back(i); } lim += x - 1; } void add1(){ q.push_front(lim++); } void solve(ll k){ if (k == 1) return; for (int i = (int)primes.size() - 1; i >= 0; i--){ if (k % primes[i] == 0){ mult(primes[i]); solve(k / primes[i]); return; } } add1(); solve(k - 1); return; } } vector<int> construct_permutation(ll k){ lim = 0; solve(k); vector<int> v; while (!q.empty()){ v.push_back(q.front()); q.pop_front(); } return v; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...