#P3916. 图的遍历
图的遍历
Description
Given a directed graph with vertices and edges, for each vertex , let denote the reachable vertex with the largest index starting from . Now compute .
Input Format
The first line contains two integers , denoting the number of vertices and edges. The next lines each contain two integers , representing the edge . Vertices are labeled .
Output Format
One line with integers .
4 3
1 2
2 4
4 3
4 4 3 4
Hint
- For of the testdata, .
- For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号