crpboy @ 2019-02-25 12:59:53
rt,72分qwq
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=10005,M=50005,INF=1000000005;
int n,m,b;
int val[N];
struct Furukawa_Nagisa
{
int v,w,nxt;
}a[M<<1];
int head[N],cnt=0;
inline void add(const int u,const int v,const int w)
{
a[++cnt].v=v;
a[cnt].w=w;
a[cnt].nxt=head[u];
head[u]=cnt;
}
int d[N];
queue<int>q;
bool vis[N];
inline bool spfa(int k)
{
if(val[1]>k)return false;
memset(d,0x7f,sizeof(d));
memset(vis,false,sizeof(vis));
d[1]=0;vis[1]=true;q.push(1);
while(!q.empty())
{
int x=q.front();q.pop();
vis[x]=false;
for(int i=head[x];i;i=a[i].nxt)
{
int v=a[i].v,w=a[i].w;
if(d[v]>d[x]+w)
{
d[v]=d[x]+w;
if(!vis[v]&&d[v]<=k)
vis[v]=true,q.push(v);
}
}
}
return d[n]<b;
}
signed main()
{
// freopen("fk_ccf.in","r",stdin);
int l=0,r=0,mid;
cin>>n>>m>>b;
for(int i=1;i<=n;i++)
scanf("%lld",&val[i]),r=max(r,val[i]);
l=max(val[1],val[n]);
for(int i=1,u,v,w;i<=m;i++)
{
scanf("%lld%lld%lld",&u,&v,&w);
if(u!=v)add(u,v,w),add(v,u,w);
}
if(!spfa(INF))return puts("AFK"),0;
while(l<=r)
{
mid=(l+r)>>1;
if(spfa(mid))r=mid-1;
else l=mid+1;
}
printf("%lld",l);
return 0;
}
by cz666 @ 2019-02-25 13:07:33
%%%
by cz666 @ 2019-02-25 13:07:44
tql啊
by 两年打铁 @ 2019-02-25 13:08:27
by DevOvO @ 2019-02-25 13:09:27
by cz666 @ 2019-02-25 13:09:32
你的图片真漂亮Orz
by DevOvO @ 2019-02-25 13:12:37
去你了个萌新
by crpboy @ 2019-02-25 13:15:00
已解决
by cz666 @ 2019-02-25 13:15:44
by 我不认识你 @ 2019-02-25 14:21:13
spfa会被卡吧
by 我不认识你 @ 2019-02-25 14:21:45
没试过