#include "machine.h"
#include <cassert>
std::vector<int> find_permutation(int N) {
if (N & 1) {
std::vector<int> A(N);
int xorsum = 0;
for (int i = 0; i < N; i++)
A[i] = i, xorsum ^= i;
std::vector<int> ans = use_machine(A);
int X = xorsum;
for (auto el : ans) X ^= el;
std::vector<int> P(N);
std::transform(ans.begin(), ans.end(), P.begin(), [X](int x) { return x ^ X; });
return P;
}
// N is even
assert(!(N & 1));
std::vector<int> A(N);
for (int i = 0; i < N - 2; i++)
A[i] = i;
A[N - 2] = N - (N % 4) / 2;
A[N - 1] = N + 2;
std::vector<int> ans = use_machine(A);
int X;
for (X = 0; X < 256; ++X) {
bool ok = true;
for (auto el : ans) {
if ((el ^ X) > N + 2) ok = false;
if ((el ^ X) == N - (N % 4 == 0)) ok = false;
}
if (ok) break;
}
std::vector<int> P(N);
std::transform(ans.begin(), ans.end(), P.begin(), [X, N](int x) {
int xx = x ^ X;
if (xx < N - 2) return xx;
if (xx == N - (N % 4) / 2) return N - 2;
if (xx == N + 2) return N - 1;
});
return P;
}
컴파일 시 표준 에러 (stderr) 메시지
machine.cpp: In lambda function:
machine.cpp:45:5: warning: control reaches end of non-void function [-Wreturn-type]
45 | });
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |