Table of Contents

ExplanationImplementation

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 uu:

  1. Node uu is not an articulation point, then the number of severed visits by removing the noed is 2×(n1)2 \times (n - 1)
  2. Node uu is an articulation point, then the number of severed visits by removing the node is 2×(n1)2 \times (n - 1) plus the number of visits whose path goes through node uu.

Implementation

Time Complexity: O(N)\mathcal{O}(N)

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!