booldfs(int u, int c, int k){ col[u] = c; for (auto &[v, w] : e[u]) { if (w <= k) continue; if (col[v] == c) returnfalse; if (!col[v] && !dfs(v, 3 - c, k)) returnfalse; } returntrue; }
intmain(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m; int low = -1; int high = INT_MAX; for (int i = 1; i <= m; ++i) { int u, v, w; cin >> u >> v >> w;
e[u].pb({v, w}); e[v].pb({u, w}); }
auto check = [&](int k) { fill(col, col + N, 0); bool flag = true; for (int i = 1; i <= n; ++i) { if (!col[i] && !dfs(i, 1, k)) { flag = false; break; } } return flag; }; while (low < high) { // cerr << "fuck" << '\n'; int mid = (low + high) / 2; if (check(mid)) high = mid - 1; else low = mid + 1; } while (!check(low)) low++; while (check(low) && low >= 0) low--; cout << low + 1 << '\n'; return0; }
vector<int> adj[N]; int f[R]; // 右部匹配的左部点 set<int> l; bitset<N> vis;
booldfs(int u){ // 从左部的节点开始搜 for (auto v : adj[u]) { if (vis[v]) continue; vis[v] = true; if (!f[v] || dfs(f[v])) { // 如果能够u v直连或者另一端也扩展,进行增广 f[v] = u; returntrue; } } returnfalse; }
intmaxMatch(int n, int m){ fill(f, f + R, 0); int ret = 0; for (auto i : l) { vis.reset(); if (dfs(i)) { ret++; } } return ret; }
intmain(){ int n, m, e; cin >> n >> m >> e; for (int i = 1; i <= e; ++i) { int u, v; cin >> u >> v; l.insert(u); adj[u].push_back(v); } cout << maxMatch(n, m) << '\n'; return0; }