含笑半步癫 @ 2018-05-25 00:01:57
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
using namespace std;
int n,m,b,cnt,last[10005],mid,rights,lefts,powe[10005],tmp;
struct edge{
int v,w,next;
}e[100500];
inline void inserts(int u,int v,int w)
{
cnt++;
e[cnt].v=v;
e[cnt].w=w;
e[cnt].next=last[u];
last[u]=cnt;
}
void read(int & x)
{
char c=getchar();x=0;
while(c<'0'||c>'9')c=getchar();
while(c>='0'&&c<='9')
x=x*10+c-48,c=getchar();
}
int spfa(int ans)
{
long long d[10005];
memset(d,0x3f3f3f,sizeof(d));
int inq[10005];
d[1]=0;
if(powe[1]>ans)
return 0;
queue<int>q;
q.push(1);
while(!q.empty())
{
int u=q.front();q.pop();
inq[u]=0;
for(int i=last[u];i;i=e[i].next)
{
int v=e[i].v,w=e[i].w;
if(d[v]>d[u]+w&&powe[v]<=ans)
{
d[v]=d[u]+w;
if(!inq[v])
{
q.push(v);
inq[v]=1;
}
}
}
}
if(d[n]<=b)
return 1;
else
return 0;
}
int main()
{
read(n);read(m);read(b);
for(int i=1;i<=n;i++)
{
read(powe[i]);
if(powe[i]>rights)
rights=powe[i];
}
for(int i=1,x,y,z;i<=m;i++)
{
read(x);read(y);read(z);
inserts(x,y,z);
inserts(y,x,z);
}
tmp=spfa(rights);
if(!tmp)
{
cout<<"AFK";
return 0;
}
while(lefts<=rights)
{
mid=(lefts+rights)>>1;
tmp=spfa(mid);
if(tmp)
rights=mid-1;
else
lefts=mid+1;
}
cout<<lefts;
return 0;
}
当b非常大且大于的d[n]的初始值时,spfa永远都会return 1,但是测试点中那些b大于初始值的点我却都通过了,求加强数据!!! @lin_toto @chen_zhe
by 含笑半步癫 @ 2018-05-25 20:42:09
@lin_toto @chen_zhe@icy
by 含笑半步癫 @ 2018-05-25 20:42:20
@icy
by icy @ 2018-05-26 21:11:34
@yjjr
by 含笑半步癫 @ 2018-05-30 22:51:57
@lin_toto @chen_zhe @yjjr @icy
by yjjr @ 2018-06-01 20:54:22
@含笑半步癫 已加入todolist!
by 含笑半步癫 @ 2018-06-20 22:50:26
@yjjr
显然还没有加强数据
by Mosklia @ 2018-06-26 17:07:59
@含笑半步癫 关于数据这回事,我只能说这题数据。。。就像闹着玩一样
我刚学最短路时,通过跑
一个月后,我自己造了一组数据
by currycodingg @ 2018-07-13 22:46:51
同感!!! 这么一个好题不加强一下数据可惜了