#include "chameleon.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
namespace {
int variable_example = 1;
} // namespace
void Solve(int N) {
vector<vector<int>> adjlist(2 * N, vector<int>());
for (int i = 0; i < 2 * N; i++)
{
for (int j = 0; j < 2 * N; j++)
{
if (i != j)
{
vector<int> a = {i + 1, j + 1};
int b = Query(a);
if (b == 1)
{
adjlist[i].push_back(j);
}
}
}
}
vector<bool> done(2 * N, false);
for (int i = 0; i < 2 * N; i++)
{
if (adjlist[i].size() == 1 && !done[i])
{
done[i] = true;
done[adjlist[i][0]] = true;
Answer(i + 1, adjlist[i][0] + 1);
}
else if (!done[i])
{
vector<int> a = {i + 1, adjlist[i][0] + 1, adjlist[i][1] + 1};
int b = Query(a);
if (b == 1)
{
adjlist[i].erase(adjlist[i].begin() + 2);
continue;
}
a = {i + 1, adjlist[i][0] + 1, adjlist[i][2] + 1};
b = Query(a);
if (b == 1)
{
adjlist[i].erase(adjlist[i].begin() + 1);
continue;
}
a = {i + 1, adjlist[i][2] + 1, adjlist[i][1] + 1};
b = Query(a);
if (b == 1)
{
adjlist[i].erase(adjlist[i].begin());
}
}
}
for (int i = 0; i < 2 * N; i++)
{
if (adjlist[i].size() != 1)
{
if (adjlist[adjlist[i][0]].size() != 1 && adjlist[adjlist[i][1]].size() != 1)
{
if ((adjlist[adjlist[i][0]][0] == i || adjlist[adjlist[i][0]][1] == i) && !done[i])
{
done[i] = true;
done[adjlist[i][0]] = true;
Answer(i + 1, adjlist[i][0] + 1);
}
else if (!done[i])
{
done[i] = true;
done[adjlist[i][1]] = true;
Answer(i + 1, adjlist[i][1] + 1);
}
}
}
}
}
Compilation message
chameleon.cpp:9:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
9 | int variable_example = 1;
| ^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
17 ms |
468 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
352 KB |
Output is correct |
7 |
Correct |
1 ms |
352 KB |
Output is correct |
8 |
Correct |
0 ms |
352 KB |
Output is correct |
9 |
Correct |
0 ms |
352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
352 KB |
Output is correct |
7 |
Correct |
1 ms |
352 KB |
Output is correct |
8 |
Correct |
0 ms |
352 KB |
Output is correct |
9 |
Correct |
0 ms |
352 KB |
Output is correct |
10 |
Correct |
3 ms |
352 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
2 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
344 KB |
Output is correct |
15 |
Correct |
2 ms |
352 KB |
Output is correct |
16 |
Incorrect |
2 ms |
456 KB |
Wrong Answer [5] |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
16 ms |
472 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
17 ms |
468 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |