# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
595758 |
2022-07-14T06:11:52 Z |
KoD |
Permutation (APIO22_perm) |
C++17 |
|
1 ms |
284 KB |
#include "perm.h"
#include <algorithm>
std::vector<int> construct_permutation(long long K) {
if (K == 1) return {};
if (K == 2) return {0};
if (K == 3) return {1, 0};
auto ret = construct_permutation(K / 4);
const int n = (int)ret.size();
if (K % 4 == 2) {
ret.push_back(n);
ret.push_back(-1);
ret.push_back(n + 1);
} else {
ret.push_back(n);
ret.push_back(n + 1);
if (K % 4 == 1) {
ret.push_back(-1);
}
if (K % 4 == 3) {
int zero = -1, one = -1;
for (int i = 0; i < n; ++i) {
if (ret[i] == 0) zero = i;
if (ret[i] == 1) one = i;
}
if (one < zero) {
for (auto& x : ret) {
if (x >= 2) x += 1;
}
ret.push_back(2);
} else {
ret.push_back(-1);
ret.push_back(-2);
}
}
}
const int min = *std::min_element(std::begin(ret), std::end(ret));
for (auto& x : ret) x -= min;
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
284 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
284 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |