#include<bits/stdc++.h>
#include "highway.h"
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
const int maxn=9e4+5;
int n,m,a,b;
vector<int>u,v;
vector<pair<int,int>>adj[maxn];
vector<int>dep(maxn,0),edge(maxn,0),w,L,R,edges;
int cur=0;
void dfs(int x,int p){
if(cur==0) L.pb(x);
else R.pb(x);
for(auto [y,e]:adj[x]){
if(y!=p){
if(cur==0){
edges.pb(e);
}
dep[y]=dep[x]+1;
edge[y]=e;
dfs(y,x);
}
}
}
void find_pair(int N,vector<int>U,vector<int>V,int A, int B){
n=N,u=U,v=V,a=A,b=B;
m=u.size();
w.resize(m);
fill(all(w),0);
ll C=ask(w);
int d=C/A;
int l=0,r=m-1;
while(l<r){
int mid=(l+r)/2;
fill(all(w),0);
for(int i=0;i<=mid;i++){
w[i]=1;
}
if(ask(w)>C){
r=mid;
}
else{
l=mid+1;
}
}
int v1=u[l],v2=v[l];
dep[v1]=0;
dep[v2]=0;
dfs(v1,v2);
cur=1;
dfs(v2,v1);
fill(all(w),0);
for(auto e:edges){
w[e]=1;
}
ll cost=ask(w);
int dep1=(C-cost)/(ll)(b-a);
int dep2=d-1-dep1;
vector<int>ver;
for(auto i:L){
if(dep[i]==dep1){
ver.pb(i);
}
}
l=0,r=ver.size()-1;
while(l<r){
int mid=(l+r)/2;
fill(all(w),0);
for(int i=0;i<=mid;i++){
w[edge[ver[i]]]=1;
}
if(ask(w)>C){
r=mid;
}
else{
l=mid+1;
}
}
int S=ver[l];
ver.clear();
for(auto i:R){
if(dep[i]==dep2){
ver.pb(i);
}
}
l=0,r=ver.size()-1;
while(l<r){
int mid=(l+r)/2;
fill(all(w),0);
for(int i=0;i<=mid;i++){
w[edge[ver[i]]]=1;
}
if(ask(w)>C){
r=mid;
}
else{
l=mid+1;
}
}
int T=ver[l];
answer(S,T);
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
3160 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3160 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
3416 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3160 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
3416 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
3672 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |