Submission #264875

#TimeUsernameProblemLanguageResultExecution timeMemory
264875BasilhijazHighway Tolls (IOI18_highway)C++11
0 / 100
21 ms1152 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...