# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
264861 | Basilhijaz | Highway Tolls (IOI18_highway) | C++11 | 0 ms | 0 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 "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;
while(lo < hi){
for(int j = lo; j < (lo + hi + 1)/2; j++){
w[adj[where][j].second] = !w[adj[where][j].second];
}
long long last = ask(w);
if(last != curr){
curr = last;
ok = 1;
hi = (lo + hi + 1)/2 - 1;
}
else{
lo = (lo + hi + 1)/2;
}
}
if(ok)where = lo;
}
answer(0, where);
}