第三个点WA了,找不到原因,救救孩子吧!
#include<queue>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=100001,M=2000001;
struct Edge{
int nex,to,cost;
}edge[M];
int n,m,k,S,E;
int tot=0,headlist[N],d[N];
bool vis[N];
inline void adds(int x,int y,int w){
edge[++tot].to=y;
edge[tot].cost=w;
edge[tot].nex=headlist[x];
headlist[x]=tot;
}
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
inline void Dijkstra(int x){
memset(d,0x3f3f3f3f,sizeof(d));
d[x]=0;
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > points;
points.push(make_pair(0,x));
while(!points.empty())
{
int u=points.top().second;
points.pop();
if(!vis[u])
{
vis[u]=true;
for(int i=headlist[u];i;i=edge[i].nex)
{
int v=edge[i].to,w=edge[i].cost;
if(d[v]>d[u]+w)
{
d[v]=d[u]+w;
points.push(make_pair(d[v],v));
}
}
}
}
}
int main(){
n=read();m=read();k=read();S=read();E=read();
int x,y,w;
for(int i=1;i<=m;i++)
{
x=read();y=read();w=read();
adds(x,y,w);adds(y,x,w);
for(int j=1;j<=k;j++)
{
adds(x+(j-1)*n,y+j*n,0);
adds(y+(j-1)*n,x+j*n,0);
adds(x+j*n,y+j*n,w);
adds(y+j*n,x+j*n,w);
}
}
for(int i=1;i<=k;i++)
adds(E+(i-1)*n,E+i*n,0);
Dijkstra(S);
printf("%d",d[E+k*n]);
return 0;
}