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 "monster.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
bool example_variable;
} // namespace
std::vector<int> Solve(int N) {
std::vector<int> T(N);
vector<int> win(N);
vector<int> order(N);
vector<int> could_be_first;
vector<int> could_be_last;
for (int i = 0 ; i < N ; i ++) {
for (int j = i + 1; j < N; j ++) {
if (i == j) continue;
if (Query(i, j)) {
win[i]++;
} else {
win[j]++;
}
}
// cout << i << " " << win << endl;
if (win[i] != 1 && win[i] != N - 2) {
order[win[i]] = i;
} else if (win[i] == 1) {
could_be_first.push_back(i);
} else {
could_be_last.push_back(i);
}
}
if (N == 4) {
if (Query(could_be_first[0], could_be_last[0])) {
order[0] = could_be_first[1];
order[1] = could_be_first[0];
order[2] = could_be_last[0];
order[3] = could_be_last[1];
} else if (Query(could_be_first[0], could_be_last[1])) {
order[0] = could_be_first[1];
order[1] = could_be_first[0];
order[2] = could_be_last[1];
order[3] = could_be_last[0];
} else if (Query(could_be_first[1], could_be_last[0])) {
order[0] = could_be_first[0];
order[1] = could_be_first[1];
order[2] = could_be_last[0];
order[3] = could_be_last[1];
} else if (Query(could_be_first[1], could_be_last[1])) {
order[0] = could_be_first[0];
order[1] = could_be_first[1];
order[2] = could_be_last[1];
order[3] = could_be_last[0];
}
} else {
if (Query(could_be_first[0], order[2])) {
order[1] = could_be_first[0];
order[0] = could_be_first[1];
} else {
order[1] = could_be_first[1];
order[0] = could_be_first[0];
}
if (Query(order[N - 3], could_be_last[0])) {
order[N - 2] = could_be_last[0];
order[N - 1] = could_be_last[1];
} else {
order[N - 2] = could_be_last[1];
order[N - 1] = could_be_last[0];
}
}
for (int i = 0; i < N ; i ++) {
T[order[i]] = i;
}
return T;
}
Compilation message (stderr)
monster.cpp:6:6: warning: '{anonymous}::example_variable' defined but not used [-Wunused-variable]
6 | bool example_variable;
| ^~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |