Advertisement
Guest User

mosts

a guest
Nov 28th, 2015
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. void dfs_bridge (int v, int p)
  2. {
  3.     times++;
  4.     t[v] = times;
  5.     dp[v] = times;
  6.     used[v] = 1;
  7.  
  8.     for (int i = 0; i < g[v].size(); i++)
  9.     {
  10.         int to = g[v][i];
  11.  
  12.         if (to != p && used[to])
  13.             dp[v] = min(dp[v], t[to]);
  14.  
  15.         if (!used[to])
  16.         {
  17.             dfs_bridge(to, v);
  18.             dp[v] = min(dp[v], dp[to]);
  19.         }
  20.     }
  21.  
  22.     if (dp[v] == t[v] && p != -1)
  23.         ans.push_back(make_pair(min(p, v), max(p, v) ));
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement