usingnamespacestd; usingnamespace FAST_IO; const ll mod = 1e9 + 7; constint INF = 0x3f3f3f3f; const ll INF_LL = 0x3f3f3f3f3f3f3f3f; constdouble eps = 1e-5; constint maxn = 1e3 + 10; constint maxm = 1e5 + 10; int t, n, m, k; vector<pair<int, int>> g[maxn]; int ans = INF; int dfn[maxn], low[maxn], dfn_clock = 0; int cnt; voidinit() { dfn_clock = 0; cnt = 0; for (int i = 1; i <= n; ++i) { g[i].clear(); dfn[i] = low[i] = 0; } ans = INF; }
voidtarjan(int u, int fa) { dfn[u] = low[u] = ++dfn_clock; ++cnt; int times = 0; for (int i = 0; i < g[u].size(); ++i) { int v = g[u][i].first; int w = g[u][i].second; if (v == fa && !times) { ++times; continue; } if (!dfn[v]) { tarjan(v, u); low[u] = min(low[u], low[v]); if (low[v] > dfn[u]) { ans = min(ans, w); } } else { low[u] = min(low[u], dfn[v]); } } }
intmain() { // #define COMP_DATA #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); #endif ios::sync_with_stdio(false); cin.tie(0); while (read(n, m), n && m) { init(); for (int i = 1, u, v, w; i <= m; ++i) { read(u, v, w); g[u].push_back({v, w}); g[v].push_back({u, w}); } tarjan(1, 0);