#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#define INF 0x3f3f3f3f
using namespace std;
struct Edge {
int to,next,dis;
} e[20005];
int head[20005],tot=0;
inline void add(int u,int v,int w) {
e[tot].to=v;
e[tot].next=head[u];
e[tot].dis=w;
head[u]=tot;
tot++;
}
int dis[10005];
bool iq[10005];
queue<int> q;
int main() {
memset(head,-1,sizeof(head));
int n,m,s,t;
scanf("%d%d%d%d",&n,&m,&s,&t);
for(int i=1; i<=m; i++) {
int u,v,w;
scanf("%d%d%d",&u,&v,&w);
add(u,v,w);
add(v,u,w);
}
memset(dis,INF,sizeof(dis));
dis[s]=0;
q.push(s);
iq[s]=1;
if(!q.empty()) {
int x=q.front();
q.pop();
iq[x]=0;
for(int i=head[x]; i!=-1; i=e[i].next)
if(dis[e[i].to]>dis[x]+e[i].dis) {
dis[e[i].to]=dis[x]+e[i].dis;
if(!iq[e[i].to]) {
iq[e[i].to]=1;
q.push(e[i].to);
}
}
}
printf("%d",dis[t]);
return 0;
}
不知道为什么queue好像抽风了QwQ