#include using namespace std; int dis[2501]; bool exist[2501];//标记每个点是否在queue中 struct point { int to; int w; }; int n,m,s,t; vector graph[2501]; void SPFA() { memset(dis, 0x3f, sizeof(dis)); dis[s] = 0; // 注意起 始点是s!!! queue q; q.push(s); exist[s]=1; while(q.size()>0) { int from=q.front(); q.pop(); exist[from]=0; for(int i=0;i> n >> m >> s >> t; for (int i = 1; i <=m ; i++) { int a,b,c; cin >> a >> b >> c; graph[a].push_back({b,c}); graph[b].push_back({a,c}); } SPFA(); cout << dis[t] << endl; return 0; }