最短路裸题
const int N=2510;
vector<PII> g[N];
int dist[N];
bool vis[N];
int n,m,s,e;
void dijkstra()
{
memset(dist,0x3f,sizeof dist);
priority_queue<PII,vector<PII>,greater<PII> > heap;
heap.push({0,s});
dist[s]=0;
while(heap.size())
{
int t=heap.top().second;
heap.pop();
if(vis[t]) continue;
vis[t]=true;
for(int i=0;i<g[t].size();i++)
{
int j=g[t][i].fi,w=g[t][i].se;
if(dist[j] > dist[t] + w)
{
dist[j]=dist[t]+w;
heap.push({dist[j],j});
}
}
}
}
int main()
{
cin>>n>>m>>s>>e;
while(m--)
{
int a,b,c;
cin>>a>>b>>c;
g[a].pb({b,c});
g[b].pb({a,c});
}
dijkstra();
cout<<dist[n]<<endl;
//system("pause");
}