#include "chameleon.h"
#include <bits/stdc++.h>
namespace {
int variable_example = 1;
}
using namespace std;
int n;
vector<int> adj[10005];
int oneway[10005];
vector<int> leftovers[10005];
bool answered[10005];
void Solve(int N) {
n = N;
for (int i = 1; i <= 2 * n; i++) {
for (int j = 1; j <= 2 * n; j++) {
if (i == j) continue;
vector<int> temp = {i, j};
int res = Query(temp);
if (res == 1) {
// an edge
adj[i].push_back(j);
}
}
if (adj[i].size() == 1) {
// mutual love case
if (answered[i] || answered[adj[i][0]]) continue;
Answer(i, adj[i][0]);
answered[i] = answered[adj[i][0]] = true;
} else {
assert(adj[i].size() == 3);
int q1 = Query({i, adj[i][0], adj[i][1]});
int q2 = Query({i, adj[i][0], adj[i][2]});
int q3 = Query({i, adj[i][1], adj[i][2]});
if (q1 == 1) {
oneway[i] = adj[i][2];
leftovers[i] = {adj[i][0], adj[i][1]};
} else if (q2 == 1) {
oneway[i] = adj[i][1];
leftovers[i] = {adj[i][0], adj[i][2]};
} else {
oneway[i] = adj[i][0];
leftovers[i] = {adj[i][1], adj[i][2]};
}
}
}
for (int i = 1; i <= 2 * n; i++) {
if (answered[i]) continue;
if (adj[i].size() == 1) continue;
if (oneway[leftovers[i][0]] == i) {
Answer(i, leftovers[i][1]);
answered[i] = answered[leftovers[i][1]] =true;
} else {
Answer(i, leftovers[i][0]);
answered[i] = answered[leftovers[i][0]] =true;
}
}
}
Compilation message
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:44:17: warning: unused variable 'q3' [-Wunused-variable]
44 | int q3 = Query({i, adj[i][1], adj[i][2]});
| ^~
chameleon.cpp: At global scope:
chameleon.cpp:6:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
6 | int variable_example = 1;
| ^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
720 KB |
Output is correct |
2 |
Correct |
1 ms |
676 KB |
Output is correct |
3 |
Incorrect |
18 ms |
792 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
720 KB |
Output is correct |
2 |
Correct |
1 ms |
720 KB |
Output is correct |
3 |
Correct |
1 ms |
720 KB |
Output is correct |
4 |
Correct |
1 ms |
720 KB |
Output is correct |
5 |
Correct |
1 ms |
720 KB |
Output is correct |
6 |
Correct |
1 ms |
720 KB |
Output is correct |
7 |
Correct |
1 ms |
720 KB |
Output is correct |
8 |
Correct |
1 ms |
720 KB |
Output is correct |
9 |
Correct |
1 ms |
720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
720 KB |
Output is correct |
2 |
Correct |
1 ms |
720 KB |
Output is correct |
3 |
Correct |
1 ms |
720 KB |
Output is correct |
4 |
Correct |
1 ms |
720 KB |
Output is correct |
5 |
Correct |
1 ms |
720 KB |
Output is correct |
6 |
Correct |
1 ms |
720 KB |
Output is correct |
7 |
Correct |
1 ms |
720 KB |
Output is correct |
8 |
Correct |
1 ms |
720 KB |
Output is correct |
9 |
Correct |
1 ms |
720 KB |
Output is correct |
10 |
Correct |
2 ms |
720 KB |
Output is correct |
11 |
Correct |
2 ms |
720 KB |
Output is correct |
12 |
Correct |
2 ms |
720 KB |
Output is correct |
13 |
Correct |
2 ms |
720 KB |
Output is correct |
14 |
Correct |
3 ms |
720 KB |
Output is correct |
15 |
Correct |
3 ms |
720 KB |
Output is correct |
16 |
Correct |
2 ms |
720 KB |
Output is correct |
17 |
Correct |
4 ms |
804 KB |
Output is correct |
18 |
Correct |
2 ms |
716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
720 KB |
Output is correct |
2 |
Correct |
1 ms |
720 KB |
Output is correct |
3 |
Incorrect |
17 ms |
796 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
720 KB |
Output is correct |
2 |
Correct |
1 ms |
676 KB |
Output is correct |
3 |
Incorrect |
18 ms |
792 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |