同https://blog.csdn.net/yanzhenhuai/article/details/82749203
#include <queue>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
#define rep(i,x,y) for(ll i=(x);i<=(y);i++)
#define repl(i,x,y) for(ll i=(x);i<(y);i++)
#define repd(i,x,y) for(ll i=(x);i>=(y);i--)
using namespace std;
const ll T=15;
const ll N=1e4+5;
const ll M=5e4+5;
const ll Inf=1e18;
ll n,m,t,st,ed,vis[N][T],dis[N][T];
ll cnt,to[M<<1],edge[M<<1],nxt[M<<1],head[N];
struct node {
ll id,del,dis;
};
inline ll read() {
ll x=0;char ch=getchar();bool f=0;
while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
return f?-x:x;
}
void ins(ll x,ll y,ll z) {
to[++cnt]=y;edge[cnt]=z;nxt[cnt]=head[x];head[x]=cnt;
}
void dij(ll s) {
priority_queue<node>q;
rep(i,1,n) rep(j,0,t) dis[i][j]=Inf;
dis[s][0]=0;q.push(node{s,0,0});
while(q.size()) {
ll x=q.top().id,del=q.top().del;q.pop();
if(vis[x][del]) continue;
vis[x][del]=1;
for(ll i=head[x];i;i=nxt[i]) {
ll y=to[i],z=edge[i];
if(dis[y][del]>dis[x][del]+z) {
dis[y][del]=dis[x][del]+z;q.push(node{y,del,dis[y][del]});
}
if(dis[y][del+1]>dis[x][del]&&del+1<=t) {
dis[y][del+1]=dis[x][del];q.push(node{y,del+1,dis[y][del+1]});
}
}
}
}
bool operator < (node p,node q) {
return p.dis>q.dis;
}
int main() {
n=read(),m=read(),t=read();
st=read()+1,ed=read()+1;
rep(i,1,m) {
ll x=read()+1,y=read()+1,z=read();ins(x,y,z),ins(y,x,z);
}
dij(st);
printf("%lld",dis[ed][t]);
return 0;
}