# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
975520 | KK_1729 | Permutation (APIO22_perm) | C++17 | 0 ms | 348 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;
int min(int x, int y){
if (x < y) return x;
return y;
}
std::vector<int> construct_permutation(long long k)
{
vector<int> a;
while (k > 2){
if (k%2 == 1){
a.push_back(1);
k--;
}else{
a.push_back(0);
k/=2;
}
}
reverse(a.begin(), a.end());
int mini = -1; int maximum = 1;
vector<int> ans;
ans.push_back(0);
for (auto x: a){
if (x == 0){
ans.push_back(maximum);
maximum++;
}else{
ans.push_back(mini);
mini--;
}
}
int u = 1e9;
for (auto x: ans){
if (x < u) u = x;
}
for (int i = 0; i < ans.size(); ++i) ans[i] += u;
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |