# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
979062 | sunnat | Permutation (APIO22_perm) | C++17 | 745 ms | 672 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 <iostream>
#include <vector>
using namespace std;
vector<int> construct_permutation(long long k){
--k;
int val = 0;
vector<int> a;
vector<long long> lstdp;
long long sum = 0;
auto calc = [&](){
sum = 0;
lstdp.resize(a.size());
for(int i = 0; i < lstdp.size(); ++ i){
lstdp[i] = 1;
for(int j = 0; j < i; ++ j)
if(a[i] > a[j]) lstdp[i] += lstdp[j];
sum += lstdp[i];
}
return sum;
};
while(sum != k){
a.push_back(a.size());
int i = a.size() - 1;
while(calc() > k){
swap(a[i], a[i-1]);
--i;
}
}
return a;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |