This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "perm.h"
#ifdef NYAOWO
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i, a, b) for(int i = a; i >= b; i--)
#define F first
#define S second
#define sz(x) ((int32_t)x.size())
#define all(x) x.begin(), x.end()
#define eb emplace_back
#define int LL
using namespace std;
using LL = long long;
using pii = pair<int, int>;
deque<int32_t> solve(int k, int32_t add) {
if(k == 1) return deque<int32_t>(0);
vector<int32_t> oao[] = {
{2, 0},
{3, 1, 0},
{5, 1, 2, 0},
{7, 1, 3, 2, 0},
};
for(auto &v:oao) if(k % v[0] == 0) {
auto a = solve(k / v[0], add + sz(v) - 1);
Forr(i, sz(v) - 1, 1) a.push_front(add + v[i]);
return a;
}
auto a = solve(k - 1, add + 1);
a.push_back(add);
return a;
}
std::vector<int32_t> construct_permutation(long long k) {
auto res = solve(k, 0);
vector<int32_t> a(all(res));
for(auto &i:a) cerr << i << " ";
cerr << "\n";
return a;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |