Graph condensation
You are given a connected directed graph with n vertices and m edges. Your task is to identify the strongly connected components of this graph and then provide a topological sort of its condensation.
Input
The input begins with a line containing two integers, n and m (1 ≤ n ≤ 20000, 1 ≤ m ≤ 200000), representing the number of vertices and edges, respectively. The following m lines each contain two integers between 1 and n, indicating the start and end vertices of an edge.
Output
First, print the total number of strongly connected components in the graph. Then, on the next line, print n integers. Each integer corresponds to a vertex and indicates the strongly connected component number to which that vertex belongs. The components should be numbered such that for any directed edge, the component number of the starting vertex is less than or equal to the component number of the ending vertex.