Submission #264864

#TimeUsernameProblemLanguageResultExecution timeMemory
264864BasilhijazHighway Tolls (IOI18_highway)C++11
0 / 100
12 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; 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); }
#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...