d %95真不知道哪错了
求dalao帮我看看
#include<iostream> #include<vector> #include<algorithm> #include<queue> using namespace std; vector<vector<vector<int>>> c; long long v[100005]; bool s[100005]; int n,m,x,y,w,d,h; bool is(long long d){ fill(v,v+n+5,1e18); fill(s,s+n+5,0); v[1]=0; priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q; q.push({0,1}); while(q.size()){ y=q.top().first,x=q.top().second; q.pop(); if(s[x])continue; s[x]=1; for(int i=0;i<c[x].size();i++){ if(c[x][i][1]<d)continue; if(0LL+y+c[x][i][2]<v[c[x][i][0]]){ v[c[x][i][0]]=0LL+y+c[x][i][2]; q.push({v[c[x][i][0]],c[x][i][0]}); } } } return v[n]<=h; } int main(){ cin>>n>>m>>h; fill(v,v+n+1,-1); c.resize(n+1); for(int i=0;i<m;i++) scanf("%d%d%d%d",&x,&y,&w,&d),c[x].push_back({y,w,d}),c[y].push_back({x,w,d}); long long l=-1,r=1e9+10; while(l+1!=r){ long long mid=(l+r)/2; if(is(mid))l=mid; else r=mid; } cout<<(is(l)?l:-1)<<endl; }