This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |