#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
monster.cpp:6:6: warning: '{anonymous}::example_variable' defined but not used [-Wunused-variable]
6 | bool example_variable;
| ^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
0 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
0 ms |
208 KB |
Output is correct |
16 |
Correct |
88 ms |
208 KB |
Output is correct |
17 |
Correct |
110 ms |
208 KB |
Output is correct |
18 |
Correct |
123 ms |
208 KB |
Output is correct |
19 |
Correct |
131 ms |
208 KB |
Output is correct |
20 |
Correct |
104 ms |
208 KB |
Output is correct |
21 |
Correct |
1 ms |
208 KB |
Output is correct |
22 |
Correct |
1 ms |
208 KB |
Output is correct |
23 |
Correct |
1 ms |
208 KB |
Output is correct |
24 |
Correct |
1 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
108 ms |
208 KB |
Output is correct |
27 |
Correct |
1 ms |
208 KB |
Output is correct |
28 |
Correct |
0 ms |
208 KB |
Output is correct |
29 |
Correct |
1 ms |
208 KB |
Output is correct |
30 |
Correct |
1 ms |
208 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
137 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
0 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
0 ms |
208 KB |
Output is correct |
16 |
Correct |
88 ms |
208 KB |
Output is correct |
17 |
Correct |
110 ms |
208 KB |
Output is correct |
18 |
Correct |
123 ms |
208 KB |
Output is correct |
19 |
Correct |
131 ms |
208 KB |
Output is correct |
20 |
Correct |
104 ms |
208 KB |
Output is correct |
21 |
Correct |
1 ms |
208 KB |
Output is correct |
22 |
Correct |
1 ms |
208 KB |
Output is correct |
23 |
Correct |
1 ms |
208 KB |
Output is correct |
24 |
Correct |
1 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
108 ms |
208 KB |
Output is correct |
27 |
Correct |
1 ms |
208 KB |
Output is correct |
28 |
Correct |
0 ms |
208 KB |
Output is correct |
29 |
Correct |
1 ms |
208 KB |
Output is correct |
30 |
Correct |
1 ms |
208 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
137 ms |
208 KB |
Output is correct |
33 |
Incorrect |
146 ms |
292 KB |
Wrong Answer [6] |
34 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
163 ms |
292 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |