P2863 [USACO06JAN] The Cow Prom S
Description
Given a directed graph with $n$ vertices and $m$ edges, find the number of strongly connected components that contain more than 1 vertex.
Input Format
The first line contains two integers $n$ and $m$.
Lines 2 through $m+1$, each line contains two integers $a$ and $b$, indicating a directed edge from $a$ to $b$.
Output Format
Output a single line containing the number of strongly connected components with more than 1 vertex.
Explanation/Hint
Constraints
For all test points, it is guaranteed that $2 \le n \le 10^4$, $2 \le m \le 5 \times 10^4$, $1 \le a, b \le n$.
Translated by ChatGPT 5