Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int timer = 0, n, m;
- vector<bool> used;
- vector<int> tin, dp;
- vector<vector<int>> g;
- set<int> ans;
- void dfs(int v, int p = -1) {
- used[v] = 1;
- tin[v] = dp[v] = timer++;
- int c = 0;
- for (auto to : g[v]) {
- if (to == p) continue;
- if (used[to]) {
- dp[v] = min(tin[to], dp[v]);
- } else {
- c++;
- dfs(to, v);
- dp[v] = min(dp[v], dp[to]);
- if (p != -1 && dp[to] >= tin[v]) {
- ans.insert(v);
- }
- }
- }
- if (p == -1 && c > 1) ans.insert(v);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement