#include"closing.h"
#include<vector>
#include<iostream>
using namespace std;
typedef long long ll;
int n,x,y;
ll k;
vector<pair<int,int>>nodes[200000];
ll distx[200000];
ll disty[200000];
void dfs1(int node,int par,ll*dists){
for(auto[ne,w]:nodes[node]){
if(ne==par)
continue;
dists[ne]=dists[ne]+w;
dfs1(ne,node,dists);
}
}
int lvl1(){
vector<bool>vis(n);
int res=0;
ll kr=k;
priority_queue<pair<ll,int>>q;
q.push({0,x});
q.push({0,y});
vis[x]=true;
vis[y]=true;
while(q.size()){
int node=q.top().second;
ll cost=q.top().first;
if(cost>kr)
break;
res++;
kr-=cost;
for(auto[ne,w]:nodes[node]){
if(vis[ne])
continue;
vis[ne]=true;
q.push({min(distx[ne],disty[ne]),ne});
}
}
return res;
}
int max_score(int N,int X,int Y,ll K,vector<int>U,vector<int>V,vector<int>W){
n=N;
x=X;
y=Y;
k=K;
for(int i=0;i<n;i++){
distx[i]=0;
disty[i]=0;
nodes[i].clear();
}
for(int i=0;i<n-1;i++){
nodes[U[i]].emplace_back(V[i],W[i]);
nodes[V[i]].emplace_back(U[i],W[i]);
}
dfs1(x,x,distx);
dfs1(y,y,disty);
int res1=lvl1();
return res1;
}
Compilation message
closing.cpp: In function 'int lvl1()':
closing.cpp:26:5: error: 'priority_queue' was not declared in this scope
26 | priority_queue<pair<ll,int>>q;
| ^~~~~~~~~~~~~~
closing.cpp:4:1: note: 'std::priority_queue' is defined in header '<queue>'; did you forget to '#include <queue>'?
3 | #include<iostream>
+++ |+#include <queue>
4 | using namespace std;
closing.cpp:26:31: error: expected primary-expression before '>' token
26 | priority_queue<pair<ll,int>>q;
| ^~
closing.cpp:26:33: error: 'q' was not declared in this scope
26 | priority_queue<pair<ll,int>>q;
| ^