Advertisement
lalalalalalalaalalla

Untitled

Oct 29th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement