# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
579800 | peuch | Permutation (APIO22_perm) | C++17 | 1098 ms | 304 KiB |
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"
#include<bits/stdc++.h>
using namespace std;
std::vector<int> construct_permutation(long long k)
{
if(k == 1) return vector<int> (0);
if(k == 2) return vector<int> (1);
vector<int> ret;
for(int i = 2; i * i <= k; i++){
if(k % i != 0) continue;
vector<int> aux1 = construct_permutation(i);
vector<int> aux2 = construct_permutation(k / i);
if(ret.empty() || aux1.size() + aux2.size() < ret.size()){
ret.clear();
for(int i = 0; i < aux1.size(); i++)
ret.push_back(aux1[i]);
for(int i = 0; i < aux2.size(); i++)
ret.push_back(aux2[i] + aux1.size());
}
}
if(ret.empty()){
ret = construct_permutation(k - 1);
ret.insert(ret.begin(), ret.size());
}
return ret;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |