Size of a strongly connected component · Compiler

Size of a strongly connected component

Count the vertices in the strongly connected component containing s. A vertex belongs if it can be reached from s and can also reach s along directed edges. Count s itself.

Input
The first line contains n, m, and s (1 <= n <= 50, 0 <= m <= n*(n-1), 1 <= s <= n). Vertices are numbered 1 through n. Each of the next m lines contains u v for an edge from u to v. There are no self-loops or duplicate directed edges.
Output
Print the size of the component containing s.

Compiler Explorer runs your code when you run or check it.

Loading your exercise draft…