#P10480. 可达性统计
可达性统计
Problem Description
Given a directed acyclic graph (DAG) with nodes and edges, count for each node how many nodes can be reached starting from that node.
Input Format
The first line contains two integers . The next lines each contain two integers , representing a directed edge from to .
Output Format
Output lines in total, where each line gives the number of nodes that can be reached from that node.
10 10
3 8
2 3
2 5
5 9
5 9
2 3
3 9
4 8
2 10
4 9
1
6
3
3
2
1
1
1
1
1
Hint
The testdata satisfies , .
Translated by ChatGPT 5