luogu#P5180. 【模板】支配树
【模板】支配树
Background
This is a template problem, with no background.
Problem Description
Given a directed graph, starting from node , find for each node the number of nodes it can dominate (including itself).
Input Format
The first line contains two positive integers , representing the number of nodes and the number of edges.
In the next lines, each line contains two integers , representing a directed edge from to .
Output Format
Output one line with integers, representing the number of nodes each node can dominate.
10 15
1 2
2 3
3 4
3 5
3 6
4 7
7 8
7 9
7 10
5 6
6 8
7 8
4 1
3 6
5 3
10 9 8 4 1 1 3 1 1 1
Hint
Constraints: , .
Translated by ChatGPT 5