# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
433295 | ioi | Highway Tolls (IOI18_highway) | C++14 | 377 ms | 21204 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 ;
const int N = 9e4 + 4 ;
long long ds[N] , vis[N] , vid , par[N];
vector<int> adj[N];
void bfs(int s){
ds[s] = 0 ;
vid ++ ;
queue<int> q ;
q.push(s);
while(q.size()){
auto fr = q.front();
q.pop();
for(auto f : adj[fr]){
if(vid != vis[f]){
vis[f] = vid ;
q.push(f);
par[f] = fr ;
ds[f] = ds[fr] + 1 ;
}
}
}
}
void find_pair(int N, std::vector<int> u, std::vector<int> v, int A, int B) {
int M = u.size() , n = N ;
map<pair<int , int > , int > mp ;
for(int i = 0 ; i < M ; i ++)
adj[u[i]].push_back(v[i]) , adj[v[i]].push_back(u[i]) , mp[{u[i] , v[i]}] = mp[{v[i] , u[i]}] = i;
vector<int> w(M , 0);
long long toll = ask(w);
bfs(0);
vector<int> poss ;
for(int i = 1 ; i < n ; i ++)
if(ds[i] == toll / A)poss.push_back(i);
int l = 0 , r = poss.size() - 1 , md ;
while(l < r){
md = (l + r ) / 2 ;
w = vector<int> (M , 0);
for(int i = l ; i <= md ; i ++)
w[mp[{par[poss[i]] , poss[i]}]] = 1 ;
long long toll2 = ask(w);
if(toll == toll2)
l = md + 1 ;
else r = md ;
// cout << l << " " << md << " " << r << endl;
}
answer(0, poss[l]);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |