$dist[v]$表示从$s$出发经过的最大的边取最小
当点$u$松弛操作$v$的时候
$dist[v] = min(dist[v], max(dist[u], w)\quad w为边长$
#include<bits/stdc++.h>
//unordered_map hash
//priority_queue<int,vector<int>,greater<int>>
//deque front back
#define endl '\n'
#define PII pair<int,int>
#define int long long
//#define int __int128
using namespace std;
inline int read();
inline void write(int x);
vector<PII> g[10005];
int dist[10005];
int st[10005];
int n, m, s, t;
void diji(int u){
priority_queue<PII, vector<PII>, greater<PII>> q;
memset(dist, 0x3f,sizeof(dist));
dist[u] = 0;
q.push({0, u});
while(q.size()){
PII t = q.top();
q.pop();
int distace = t.first, u = t.second;
if(st[u]) continue;
st[u] = 1;
for(int i = 0; i < g[u].size(); ++ i){
int v = g[u][i].first, w = g[u][i].second;
if(dist[v] > max(dist[u], w)){
dist[v] = max(dist[u], w);
q.push({dist[v], v});
}
}
}
}
void solve(){
n = read(), m = read(), s = read(), t = read();
for(int i = 1; i <= m; ++ i){
int u = read(), v = read(), w = read();
g[u].push_back({v, w});
g[v].push_back({u, w});
}
diji(s);
cout << dist[t];
}
signed main(){
int _ = 1;
while(_ --) solve();
return 0;
}
inline int read(){
int x=0,f=1;char c=getchar();
while(c<'0'||c>'9'){
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=getchar();
return x*f;
}
inline void write(int x){
if(x < 0) putchar('-'), x = - x;
if(x > 9) write(x / 10);
putchar('0' + x % 10);
}