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;
#define ll long long
void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
int M = U.size();
vector<vector<pair<int,int>>> g(N);
for (int i=0; i<M; i++){
g[U[i]].push_back({V[i], i});
g[V[i]].push_back({V[i], i});
}
vector<int> f(M, 0);
ll d = ask(f)/A;
vector<int> dist(N, -1);
queue<int> q;
q.push(0);
dist[0] = 0;
vector<pair<int,int>> pos;
while (!q.empty()){
int cur = q.front();
q.pop();
for (pair<int,int> next : g[cur]){
if (dist[next.first] != -1) continue;
dist[next.first] = dist[cur]+1;
if (dist[next.first] == d) pos.push_back(next);
else q.push(next.first);
}
}
int l = 0, r = pos.size();
while (l != r-1){
int m = (l+r)/2;
vector<int> w(M, 0);
for (int i=l; i<m; i++) w[pos[i].second] = 1;
if (ask(w) > d*A) r = m;
else l = m;
}
answer(0, pos[l].first);
}
# | 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... |