# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
263254 | salma | Highway Tolls (IOI18_highway) | C++14 | 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);
vector<pair<int,int> > adj[N+1];
for(int i=0;i<M;i++){
adj[V[i]].push_back({U[i] , i});
adj[U[i]].push_back({V[i] , i});
}
for (int i = 0; i < M; ++i) {
w[i] = 0;
}
long long toll = ask(w);
int cnt = toll/A;
int ans1 = 0;
set<int>s;
s.insert(0)
for(int i=0;i<adj[ans1].size();i++){
if(cnt==0)break;
if(s.count(adj[ans1][i]))continue;
w[adj[ans1][i].second]=1;
if(toll != ask(w)){
ans1 = adj[ans1][i];
i=0; cnt--;
}
w[adj[ans1][i].second] = 0;
}
answer(0 , ans1);
}