# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
263246 | NicolaAbusaad2014 | 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;
long long mn,a,m;
int T;
map<long,map<long,long> >mp;
vector<long long>edges;
void dfs(long n,long p,long d)
{
if(d==mn){
std::vector<int> w(m);
for (int i = 0; i < m; ++i) {
w[i] = 0;
if(i==mp[n][p]){
w[i]=1;
}
}
long long toll = ask(w);
if(toll>(mn*a)){
T=n;
}
return;
}
for(long i=0;i<(long)edges(n).size();i++){
dfs(edges[n][i],n,d+1);
}
}
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
a=A;
m=M;
int M = U.size();
vector<int> w(M);
for (int i = 0; i < M; ++i) {
w[i] = 0;
}
mn=(ask(w)/A);
edges.resize(N);
for(long i=0;i<M;i++){
edges(V[i]).push_back(U[i]);
edges(U[i]).push_back(V[i]);
mp[V[i]][U[i]]=i;
mp[U[i]][V[i]]=i;
}
dfs(0,0,0);
answer(0,T);
}