#include"bits/stdc++.h" //#include using namespace std; #define print(x) cout< PI; typedef pair V; typedef vector VE; const ll mod = 100000000; int n, m, s, g; int a[20000], b[20000], c[20000]; int d[202]; bool used[202]; int cost[202][202]; int pr[202]; void dijkstra(int s) { REP(i, n)d[i] = mod; REP(i, n)used[i] = 0; d[s] = 0; while (true) { int v = -1; REP(u, n) { if (!used[u] && (v == -1 || d[u] < d[v]))v = u; } if (v == -1)break; used[v] = true; REP(u, n) { if (d[u] > d[v] + cost[v][u]) { d[u] = d[v] + cost[v][u]; pr[u] = v; } else if (d[u] == d[v] + cost[v][u]) { pr[u] = min(pr[u], v); } } } } VE get_path(int t) { VE path; for (; t != -1; t = pr[t])path.push_back(t); reverse(path.begin(), path.end()); return path; } int main() { cin >> n >> m >> s >> g; REP(i, 202)REP(j, 202)cost[i][j] = mod; REP(i, m) { cin >> a[i] >> b[i] >> c[i]; cost[a[i]][b[i]] = c[i]; cost[b[i]][a[i]] = c[i]; } dijkstra(g); //VE v = get_path(s); VE v; int now = s; int i = 0; while (now != g) { v.push_back(now); now = pr[now]; } v.push_back(g); //print(d[g]); REP(i,v.size())cout<