SHARE
TWEET

Untitled

lalalalalalalaalalla Oct 29th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int timer = 0, n, m;
  2. vector<bool> used;
  3. vector<int> tin, dp;
  4. vector<vector<int>> g;
  5. set<int> ans;
  6.  
  7. void dfs(int v, int p = -1) {
  8.     used[v] = 1;
  9.     tin[v] = dp[v] = timer++;
  10.     int c = 0;
  11.     for (auto to : g[v]) {
  12.         if (to == p) continue;
  13.         if (used[to]) {
  14.             dp[v] = min(tin[to], dp[v]);
  15.         } else {
  16.             c++;
  17.             dfs(to, v);
  18.             dp[v] = min(dp[v], dp[to]);
  19.             if (p != -1 && dp[to] >= tin[v]) {
  20.                 ans.insert(v);
  21.             }
  22.         }
  23.     }
  24.     if (p == -1 && c > 1) ans.insert(v);
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top