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;
}

全部评论

相关推荐

好在哪里了?我请问了?
_hengheng:很好啊,我看旁边同事都入职了都有工作
点赞 评论 收藏
分享
学历算污点吗?
小何和:快毕业了,BOSS上的od闻着味就来了
点赞 评论 收藏
分享
昨天 11:28
门头沟学院 Java
flmz_Kk:爷们要脸儿
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
06-18 22:30
我看都是谁在卷前端!
秋盈丶:搜了下,20人的公司能收到2000份招呼?真有这么夸张吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务