#include <bits/stdc++.h>
#include "monster.h"
using namespace std;
namespace {
bool example_variable;
} // namespace
vector<int> Solve(int N) {
vector<int> T(N);
bool win[N + 10][N + 10];
int cnt[N + 10], wg[N + 10];
memset(cnt, 0, sizeof(cnt));
vector<int> g[N + 10];
for (int i = 0; i < N; i++) {
for (int j = i + 1; j < N; j++) {
win[i][j] = Query(i, j);
win[j][i] = !win[i][j];
if (win[i][j]) {
cnt[i]++;
wg[i] = j;
g[i].push_back(j);
}
else {
cnt[j]++;
wg[j] = i;
g[j].push_back(i);
}
}
}
int zero;
vector<int> v;
for (int i = 0; i < N; i++) {
if (cnt[i] == 1) {
v.push_back(i);
}
}
zero = v[0];
if (v.size() > 1) {
if (win[wg[v[0]]][wg[v[1]]]) {
}
else {
zero = v[1];
}
}
T[zero] = 0;
bool visited[N + 10];
memset(visited, 0, sizeof(visited));
visited[zero] = 1;
queue<int> q;
q.push(zero);
int num = 1;
while (q.size()) {
int f = q.front();
q.pop();
for (auto x : g[f]) {
if (visited[x]) continue;
T[x] = num++;
visited[x] = 1;
q.push(x);
}
}
return T;
}
Compilation message
monster.cpp:8:6: warning: '{anonymous}::example_variable' defined but not used [-Wunused-variable]
8 | bool example_variable;
| ^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
596 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
89 ms |
1332 KB |
Output is correct |
17 |
Correct |
86 ms |
1800 KB |
Output is correct |
18 |
Correct |
105 ms |
1304 KB |
Output is correct |
19 |
Correct |
102 ms |
1536 KB |
Output is correct |
20 |
Correct |
105 ms |
1780 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
0 ms |
344 KB |
Output is correct |
24 |
Correct |
0 ms |
344 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
100 ms |
748 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
29 |
Correct |
0 ms |
344 KB |
Output is correct |
30 |
Correct |
0 ms |
344 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
92 ms |
1304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
596 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
89 ms |
1332 KB |
Output is correct |
17 |
Correct |
86 ms |
1800 KB |
Output is correct |
18 |
Correct |
105 ms |
1304 KB |
Output is correct |
19 |
Correct |
102 ms |
1536 KB |
Output is correct |
20 |
Correct |
105 ms |
1780 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
0 ms |
344 KB |
Output is correct |
24 |
Correct |
0 ms |
344 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
100 ms |
748 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
29 |
Correct |
0 ms |
344 KB |
Output is correct |
30 |
Correct |
0 ms |
344 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
92 ms |
1304 KB |
Output is correct |
33 |
Incorrect |
118 ms |
2520 KB |
Wrong Answer [6] |
34 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
109 ms |
2324 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |