393. Components of Exactly This Size
Print how many connected components have exactly k vertices.
Problem 367 kept the largest size and problem 363 counted components. This
keeps every size and compares each against k, which needs no more machinery
than either of them.
Isolated vertices are components of size 1, so with k = 1 they are exactly
what is being counted. That is the case a solution driven by the edge list
misses entirely.
Constraints - `1 ≤ n ≤ 100000` - `0 ≤ m ≤ 200000` - `1 ≤ k ≤ n` - There are no self-loops and no repeated edges.
Input
The first line contains three integers n, m and k: the number of
vertices, the number of edges, and the size to count. Each of the next m
lines contains two integers u and v, an undirected edge. Vertices are
numbered 1 to n.
Output
Print one integer, the number of components holding exactly k vertices.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.