Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vector<vector<pair<int, int>>> g;
- vector<int> used;
- vector<int> up;
- vector<int> tin;
- vector<int> ans;
- int timer = 0;
- void dfs(int v, int parent, int parent_edge) {
- tin[v] = up[v] = timer++;
- used[v] = 1;
- for (auto[u, edge] : g[v]) {
- if (u == parent && edge == parent_edge) {
- continue;
- }
- if (used[u]) {
- up[v] = min(up[v], tin[u]);
- } else {
- dfs(u, v, edge);
- up[v] = min(up[v], up[u]);
- if (up[u] > tin[v]) {
- ans.push_back(edge);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment