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>
using namespace std;
void answer(int a, int b) {
Answer(++a, ++b);
}
vector<int> without(int a, int b, int N) {
vector<int> ans;
++a; ++b;
for (int i = 1; i <= 2 * N; i++) {
if (i != a && i != b) {
ans.push_back(i);
}
}
return ans;
}
void solve(int N) {
vector<bool> done(2 * N);
for (int i = 0; i < 2 * N; i++) {
if (done[i]) continue;
for (int j = 0; j < i; j++) {
if (done[j]) continue;
if (Query(vector<int>{i + 1, j + 1}) == 1) {
done[i] = done[j] = 1;
answer(i, j);
break;
}
}
}
}
void Solve(int N) {
if (N < 50) {
solve(N);
return;
}
vector<bool> done(2 * N);
vector<vector<int>> crit(2 * N);
for (int i = 0; i < 2 * N; i++) {
for (int j = 0; j < i; j++) {
if (Query(vector<int>{i + 1, j + 1}) == 1) {
crit[i].push_back(j);
crit[j].push_back(i);
}
}
}
for (int i = 0; i < 2 * N; i++) {
if (done[i]) continue;
for (int j = 0; j < (signed) crit[i].size(); j++) {
if (done[crit[i][j]]) continue;
if (Query(without(i, crit[i][j], N)) <= N - 1) {
answer(i, crit[i][j]);
done[crit[i][j]] = 1;
done[i] = 1;
}
}
}
}
# | 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... |