水题,RE,求助

P1462 通往奥格瑞玛的道路

EEchoyukii @ 2020-03-27 11:04:49

只过了第11个点qwq

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
#define int long long 
inline int read(){
    register int x=0,f=0,ch=getchar();
    while('0'>ch||ch>'9')f^=ch=='-',ch=getchar();
    while('0'<=ch&&ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=getchar();
    return f?-x:x;
}
const int MAX=10005;
int n,m,b;
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >q;
struct E{
    int e,next,w;
}e[MAX<<1];
int head[MAX],cnt=1;
inline void add(int u,int v,int w){
    e[cnt]=(E){v,head[u],w};
    head[u]=cnt++;
}
int x,dis[MAX],vis[MAX],f[MAX],c[MAX];
inline bool check(int s){
    memset(dis,0x3f,sizeof(dis));
    memset(vis,0,sizeof(vis));
    dis[1]=0;q.push(make_pair(0,1));
    while(!q.empty()){
        x=q.top().second;q.pop();
        if(!vis[x]){
            vis[x]=1;
            for(register int i=head[x];i;i=e[i].next){
                if(dis[e[i].e]>dis[x]+e[i].w&&f[e[i].e]<=s){
                    dis[e[i].e]=dis[x]+e[i].w;
                    q.push(make_pair(dis[e[i].e],e[i].e));
                }
            }
        }
    }
    return dis[n]<=b;
}
int l,r,mid,s,t,v,ans;
signed main(){
    n=read(),m=read();b=read();
    for(register int i=1;i<=n;++i)f[i]=c[i]=read();
    for(register int i=1;i<=m;++i){
        s=read(),t=read(),v=read();
        add(s,t,v);add(t,s,v);
    }
    sort(c+1,c+1+n);
    if(!check(c[n]))return printf("AFK\n"),0;
    l=1,r=n;
    while(l<=r){
        mid=l+r>>1;
        if(check(c[mid])){
            ans=c[mid];
            r=mid-1;
        }else l=mid+1;
    }
    printf("%lld\n",ans);
    return 0;
}

by genshinimpactplayer @ 2020-03-27 11:08:39

qndst


by liqingyang @ 2020-03-27 11:11:20

@AK永动机 orz 蓝题水题!


by EEchoyukii @ 2020-03-27 11:13:09

各位神仙不要发无意义言论啊,这是求助帖,谢谢


by EEchoyukii @ 2020-03-27 11:13:21

@qym2008 @inoichi @liqingyang


by xhQYm @ 2020-03-27 11:14:28

@AK永动机 哦抱歉啊。


by zsaskk @ 2020-03-27 11:26:57

@AK永动机 emm

数 组 开 小 了

const int MAX=10005;
struct E{
    int e,next,w;
}e[MAX<<1];

by zsaskk @ 2020-03-27 11:27:34

你是不是最近求助都是我终结的啊qwq


by EEchoyukii @ 2020-03-27 11:29:23

@zsaskk 好像是的呢,Orz省选dalao


by 洛谷Onlinejudge @ 2020-07-07 10:28:46

快读里的两个变量开成long long int

不开会爆的


|