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;
set <int> candidate;
int c1 , c2;
const int N = 2e5;
vector <pair<int,int>> adj[N];
vector <int> to_ask;
long long ans;
void dfs (int u = 0 , int p = -1 , long long cur = 0){
if (cur == ans)
candidate.insert(u);
if (cur != ans && candidate.count(u))
candidate.erase(u);
for (auto v : adj[u])
if (v.first ^ p)
dfs(v.first,u,cur + (to_ask[v.second] ? c1 : c2));
}
void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
int M = U.size();
c1 = A;
c2 = B;
for (int i = 0 ; i < M ; ++i){
adj[U[i]].push_back({V[i],i});
adj[V[i]].push_back({U[i],i});
}
for (int i = 0 ; i < M ; ++i){
to_ask = vector <int> (M,0);
to_ask[i] = 1;
ans = ask(to_ask);
dfs();
}
answer(0,*candidate.begin());
}
# | 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... |