_no0B

Untitled

Nov 28th, 2021
653
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. #define N ((int)6e4 + 5)
  4. #define MOD ((int)1e9 + 7)
  5. #define MAX ((int)1e9 + 7)
  6. #define MAXL ((ll)1e18 + 7)
  7. #define MAXP ((int)1e3 + 7)
  8. #define thr 1e-8
  9. #define pi acos(-1)  /// pi = acos ( -1 )
  10. #define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
  11. #define endl "\n"
  12.  
  13. using namespace std;
  14.  
  15. vector < int > art;
  16.  
  17. vector < pair < int , int > > bridge;
  18.  
  19. void dfs(int n , int p)
  20. {
  21.     reach[n] = dep[n] = dep[p] + 1;
  22.     vis[n] = 1;
  23.  
  24.     int cnt = 0;
  25.  
  26.     for(int a:adj[n]){
  27.         if(a == p){
  28.             p = -1;
  29.             continue;
  30.         }
  31.         else if(vis[a] == 0){
  32.             cnt++;
  33.             dfs(a , n);
  34.             if(reach[a] >= dep[n] && n != root) art.push_back(n);
  35.             if(reach[a] > dep[n]) bridge.push_back({n , a});
  36.             reach[n] = min(reach[n] , reach[a]);
  37.         }
  38.         else if(dep[a] < dep[n]){
  39.             reach[n] = min(reach[n] , dep[a]);
  40.         }
  41.     }
  42.  
  43.     if(n == root && cnt > 1) art.push_back(n);
  44. }
RAW Paste Data