Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int dfs_num[mx], dfs_cnt, dfs_low[mx], dfs_parent[mx], n, vis[mx], root, child, art_ver[mx];
- vector <int> graph[mx];
- void init(){
- dfs_cnt = 1;
- for(int j=1;j<=n;j++){
- if(dfs_num[j]==0){
- root = j; child = 0;
- articulationpoint(j);
- art_ver[j] = (child>1);
- }
- }
- ans = 0;
- for(int j=1;j<=n;j++){
- if(art_ver[j]){
- ans++;
- }
- }
- }
- void articulationpoint(int u){
- dfs_low[u] = dfs_num[u] = dfs_cnt++;
- for(int i=0;i<graph[u].size();i++){
- if(dfs_num[graph[u][i]] == 0){
- dfs_parent[graph[u][i]] = u;
- if(u==root){
- child++;
- //cout << "root " << graph[u][i] <<" ";
- }
- articulationpoint(graph[u][i]);
- if(dfs_low[graph[u][i]]>=dfs_num[u]){
- art_ver[u] = 1;
- }
- dfs_low[u] = min(dfs_low[u], dfs_low[graph[u][i]]);
- }
- else if(graph[u][i]!=dfs_parent[u]){
- dfs_low[u] = min(dfs_low[u], dfs_num[graph[u][i]]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement