#include "chameleon.h"
#include <bits/stdc++.h>
#define pii pair<int, int>
using namespace std;
const int MAX = 505;
vector<int> G[MAX];
int checked[MAX];
void Solve(int N) {
N <<= 1;
for (int i = 1; i <= N; ++i) {
for (int j = i + 1; j <= N; ++j) {
vector<int> go = {i, j};
int c = Query(go);
if (c == 1) {
G[i].push_back(j);
G[j].push_back(i);
}
}
}
vector<pii> ans;
for (int i = 1; i <= N; ++i) {
if (checked[i]) continue;
if (G[i].size() == 1) {
ans.emplace_back(i, G[i][0]);
checked[i] = checked[G[i][0]] = 1;
}
else if (G[i].size() == 3) {
for (int k = 0; k < 3; ++k) {
if (checked[G[i][k]]) continue;
int a = i, b = G[i][k];
vector<int> remain = G[a];
for (int n : G[b]) remain.push_back(n);
int same = 0;
for (int n : remain) {
if (n == a || n == b) continue;
vector<int> go = {a, b, n};
int c = Query(go);
if (c == 1) same++;
}
if (same == 2) {
ans.emplace_back(a, b);
checked[a] = checked[b] = 1;
break;
}
}
}
else exit(99);
}
for (auto [a, b] : ans) Answer(a, b);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Runtime error |
2 ms |
464 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
336 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
336 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
2 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Runtime error |
2 ms |
464 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |