#include <bits/stdc++.h>
#include "chameleon.h"
using namespace std;
#define ar array
#define sz(v) int(std::size(v))
using i64 = long long;
const int MAXN = 505 * 2;
vector<int> adj[MAXN];
int who[MAXN], nex[MAXN], pre[MAXN];
void Solve(int N) {
if (N <= 50) {
for (int i = 1; i <= N * 2; i++)
for (int j = i + 1; j <= N * 2; j++)
if (Query({i, j}) == 1) {
adj[i].push_back(j);
adj[j].push_back(i);
}
for (int i = 1; i <= N * 2; i++) {
assert(sz(adj[i]) == 1 || sz(adj[i]) == 3);
if (sz(adj[i]) == 1) {
who[i] = adj[i][0];
} else {
nex[i] = [&]() {
if (Query({i, adj[i][0], adj[i][1]}) == 1) return adj[i][2];
if (Query({i, adj[i][0], adj[i][2]}) == 1) return adj[i][1];
return adj[i][0];
}();
pre[nex[i]] = i;
}
}
for (int i = 1; i <= N * 2; i++) {
if (!who[i]) {
assert(sz(adj[i]) == 3);
assert(pre[i] && nex[i]);
who[i] = adj[i][0] ^ adj[i][1] ^ adj[i][2] ^ pre[i] ^ nex[i];
}
if (who[i] < i) Answer(who[i], i);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
504 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 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 |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
2 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
504 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |