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 <bits/stdc++.h>
#include <monster.h>
using namespace std;
bool Query(int a, int b);
std::vector<int> Solve(int N) {
vector<int> T(N);
if(N == 1) return T;
vector<int> win(N);
for(int i = 0; i < N; i++) {
for(int j = i + 1; j < N; j++) {
if(Query(i, j)) ++win[i];
else ++win[j];
}
}
for(int i = 0; i < N; i++) {
if(win[i] < N - 2 && win[i] > 1)
T[i] = win[i];
}
if(N == 2) {
for(int i = 0; i < N; i++)
T[i] = 1 - win[i];
return T;
}
for(int i = 0; i < N; i++) {
for(int j = i + 1; j < N; j++) {
if(win[i] == 1 && win[j] == 1) {
if(Query(i, j))
T[i] = 0, T[j] = 1;
else
T[i] = 1, T[j] = 0;
}
}
}
for(int i = 0; i < N; i++) {
for(int j = i + 1; j < N; j++) {
if(win[i] == N - 2 && win[j] == N - 2)
if(Query(i, j))
T[i] = N - 2, T[j] = N - 1;
else
T[i] = N - 1, T[j] = N - 2;
}
}
return T;
}
Compilation message (stderr)
monster.cpp: In function 'std::vector<int> Solve(int)':
monster.cpp:38:15: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
38 | if(win[i] == N - 2 && win[j] == N - 2)
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |