# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
751902 | puppy | Chameleon's Love (JOI20_chameleon) | C++17 | 20 ms | 348 KiB |
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 <vector>
#include <cassert>
#include <iostream>
using namespace std;
namespace {
int variable_example = 1;
int love[1005];
int by[1005];
vector<int> one[1005];
bool used[1005];
} // namespace
void Solve(int N) {
if (N == 2) {
for (int i = 1; i <= 2 * N; i++) {
for (int j = i + 1; j <= 2 * N; j++) {
vector<int> v; v.push_back(i); v.push_back(j);
if (Query(v) == 1) {
Answer(i, j);
}
}
}
return;
}
for (int i = 1; i <= 2 * N; i++) {
for (int j = 1; j <= 2 * N; j++) {
if (i == j) continue;
vector<int> v; v.push_back(i); v.push_back(j);
if (Query(v) == 1) one[i].push_back(j);
}
if (one[i].size() == 1) {
int tst = one[i][0];
if (used[i] || used[tst]) continue;
Answer(i, tst);
used[i] = true;
used[tst] = true;
}
else {
for (int p = 0; p < 3; p++) {
for (int q = p + 1; q < 3; q++) {
vector<int> v;
v.push_back(i); v.push_back(one[i][p]); v.push_back(one[i][q]);
if (Query(v) == 1) {
love[i] = one[i][3-p-q];
}
}
}
}
}
for (int i = 1; i <= 2 * N; i++) by[love[i]] = i;
for (int i = 1; i <= 2 * N; i++) {
if (used[i]) continue;
int to = -1;
to = one[i][0] + one[i][1] + one[i][2] - love[i] - by[i];
Answer(i, to);
used[i] = used[to] = true;
}
}
Compilation message (stderr)
# | 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... |