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 "highway.h"
#include <bits/stdc++.h>
using namespace std;
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
int M = U.size();
vector<int> w(M);
for(int i = 0; i < M; i++){
w[i] = 0;
}
vector<vector<pair<int, int> > > adj(N);
for(int i = 0; i < M; i++){
adj[U[i]].push_back({V[i], i});
adj[V[i]].push_back({U[i], i});
}
long long curr = ask(w);
int where = 0;
bool ok = 1;
while(ok){
ok = 0;
int lo = 0; int hi = adj[where].size() - 1;
int best = -1;
while(lo <= hi){
int mid = (lo + hi)/2;
for(int j = lo; j <= mid; j++){
w[adj[where][j].second] = !w[adj[where][j].second];
}
long long last = ask(w);
if(last != curr){
hi = mid - 1;
ok = 1;
best = mid;
curr = last;
}
else{
lo = mid + 1;
}
}
if(ok)where = best;
}
answer(0, where);
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |