# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
937331 | freedommo33 | Chameleon's Love (JOI20_chameleon) | C++17 | 1 ms | 344 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 <iostream>
using namespace std;
// Function to find a pair given one of the chameleons
void findPair(int n, int x, vector<bool>& found) {
int low = 1, high = 2 * n, mid;
while (low < high) {
mid = (low + high) / 2;
vector<int> query = {x};
for (int i = 1; i <= mid; ++i) {
if (!found[i]) query.push_back(i);
}
int result = Query(query);
if (result < query.size()) {
high = mid;
} else {
low = mid + 1;
}
}
Answer(x, low);
found[x] = found[low] = true;
}
void Solve(int N) {
vector<bool> found(2 * N + 1, false);
for (int i = 1; i <= 2 * N; ++i) {
if (!found[i]) {
findPair(N, i, found);
}
}
}
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... |