#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];
}
}
cout << zero << endl;
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;
| ^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [0] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [0] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
111 ms |
2308 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |