# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
217163 | rama_pang | Chameleon's Love (JOI20_chameleon) | C++14 | 67 ms | 504 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 <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> edges; // edges(a, b) if Query({a, b}) = 1
void FindEdges(vector<int> candidates, int n) { // find edges from one of vertices in candidates to i
int lo = 0, hi = (int) candidates.size() - 1;
while (lo < hi) {
int mid = (lo + hi) / 2;
vector<int> q(begin(candidates), begin(candidates) + mid + 1);
q.emplace_back(n);
if (Query(q) < q.size()) {
hi = mid;
} else {
lo = mid + 1;
}
}
edges.emplace_back(candidates[hi], n); // set(candidates[1...hi] + n) has an edge while set(candidates[1...hi-1] + n) doesn't, means there is an edge between candidates[hi] and n
vector<int> new_candidates(begin(candidates) + hi + 1, end(candidates));
vector<int> q(new_candidates);
q.emplace_back(n);
if (Query(q) < q.size()) { // there is an edge between new_candidates and n
return FindEdges(new_candidates, n);
}
}
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... |