文件目录

#include <bits/stdc++.h>
using namespace std;
struct edge
{
    int v, w;
};
vector<edge> v[2550];
int t, c, ts, te, s, e, ci;
int dis[2550];
bool vis[2550];
void dijk(int s, int e)
{
    memset(dis, 0x3f, sizeof(dis));
    dis[s] = 0;
    while (true)
    {
        int k = 0;
        for (int i = 1; i <= t; i++)
            if (vis[i] == false && dis[k] > dis[i])
                k = i;
        if (k == e)
            break;
        vis[k] = 1;
        for (int i = 0; i < v[k].size(); i++)
            if (vis[v[k][i].v] == false && dis[v[k][i].v] > dis[k] + v[k][i].w)
                dis[v[k][i].v] = dis[k] + v[k][i].w;
    }
}
int main()
{
    cin >> t >> c >> ts >> te;
    while (c--)
    {
        cin >> s >> e >> ci;
        v[s].push_back({e, ci});
        v[e].push_back({s, ci});
    }
    dijk(ts, te);
    cout << dis[te];
    return 0;
}