Explanation
The number of severed visits can be computed at the same time while searching for articulation points. There are two cases to consider for node :
- Node is not an articulation point, then the number of severed visits by removing the noed is
- Node is an articulation point, then the number of severed visits by removing the node is plus the number of visits whose path goes through node .
Implementation
Time Complexity:
C++
#include <bits/stdc++.h>using namespace std;int main() {int n, m;cin >> n >> m;vector<vector<int>> g(n + 1);for (int i = 0; i < m; i++) {int x, y;cin >> x >> y;
Join the USACO Forum!
Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!