1 #include <bits/stdc++.h>
2 #define ll long long
3 using namespace std;
4 const int N=1000100;
5 const int M=9e6+10;
6 struct node
7 {
8 int next,to,w;
9 } e[M];
10 int h[N],v[N],d[N],tot;
11
12 int n,m,s,t,k,ans;
13 void add(int u,int v,int w){
14 tot++;
15 e[tot].to=v;
16 e[tot].w=w;
17 e[tot].next=h[u];
18 h[u]=tot;
19 }
20
21 priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >q;
22 void dij(int s){
23 memset(d,0x3f3f3f3f,sizeof(d));
24 d[s]=0;
25 q.push(make_pair(0,s));
26 while (!q.empty()){
27 int u=q.top().second;
28 q.pop();
29 if (v[u]){
30 continue;
31 }
32 v[u]=1;
33 for (int i=h[u];i;i=e[i].next){
34 int to=e[i].to;
35 if (d[to]>d[u]+e[i].w){
36 d[to]=d[u]+e[i].w;
37 q.push(make_pair(d[to],to));
38 }
39 }
40 }
41 }
42 int main()
43 {
44 scanf("%d%d%d%d%d",&n,&m,&s,&t,&k);
45 for (int i=1; i<=m; i++)
46 {
47 int u,v,w;
48 scanf("%d%d%d",&u,&v,&w);
49 add(u,v,w);
50 add(v,u,w);
51 for (int j=1; j<=k; j++)
52 {
53 add(u+n*(j-1),v+j*n,0);
54 add(v+n*(j-1),u+j*n,0);
55 add(u+n*j,v+j*n,w);
56 add(v+n*j,u+j*n,w);
57 }
58 }
59 dij(s);
60 ans=0x3f3f3f3f;
61 for (int i=0;i<=k;i++){
62 ans=min(ans,d[k*n+t]);
63 }
64 printf("%d\n",ans);
65 return 0;
66 }