#include<bits/stdc++.h>
#include "perm.h"
using namespace std;
#define vi vector<int>
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
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(), all(r));
return l;
}
}
vi a = construct_permutation(k / 2);
a.pb(a.size());
if(k & 1) a.insert(a.begin(), a.size());
return a;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
304 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
372 KB |
Output is correct |
13 |
Correct |
3 ms |
340 KB |
Output is correct |