0
已解决
李庚午
中级守护
中级守护
莫名WA55分,目测应当是二分的问题,蒟蒻求救。
#include<bits/stdc++.h>
using namespace std;
const int maxn=10003;
typedef long long ll;
struct edge
{
ll to,dist;
};
vector<edge>G[maxn];
ll n,m,t;
ll c[maxn];
bool spfa(ll x)
{
deque<ll>team;team.push_front(1);
bool vis[maxn];memset(vis,false,sizeof(vis));vis[1]=true;
ll dis[maxn];memset(dis,127,sizeof(dis));dis[1]=true;
while(!team.empty())
{
ll q=team.front();team.pop_front();vis[q]=false;
for(ll i=0;i<G[q].size();i++)
{
edge e=G[q][i];
if (dis[e.to]>dis[q]+e.dist&&c[e.to]<=x)
{
dis[e.to]=dis[q]+e.dist;
if (!vis[e.to])
{
if (team.empty()||dis[e.to]<dis[team.front()]) team.push_front(e.to);
else team.push_back(e.to);
}
}
}
}
if (dis[n]>=t) return false;
return true;
}
int main()
{
scanf("%lld %lld %lld",&n,&m,&t);
for(ll i=1;i<=n;i++) scanf("%lld",&c[i]);
for(ll i=1;i<=m;i++)
{
ll u,v,w;
scanf("%lld %lld %lld",&u,&v,&w);
G[u].push_back((edge){v,w});
G[v].push_back((edge){u,w});
}
ll l=1,r=10000000001;
while(l<=r)
{
//printf("L:%lld ; R:%lld\n",l,r);
ll mid=(l+r)/2;
if (spfa(mid)) r=mid-1;
else l=mid+1;
}
if (spfa(l)) printf("%lld",l);
else printf("error404");
return 0;
}
我不缺可以AC的代码。我只要您指出我的错误。
0
0
0
0
0
0
0
0