luogu#P5180. 【模板】支配树

【模板】支配树

Background

This is a template problem, with no background.

Problem Description

Given a directed graph, starting from node 11, find for each node the number of nodes it can dominate (including itself).

Input Format

The first line contains two positive integers n,mn, m, representing the number of nodes and the number of edges.

In the next mm lines, each line contains two integers u,vu, v, representing a directed edge from uu to vv.

Output Format

Output one line with nn 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: n2×105n \le 2 \times 10^5, m3×105m \le 3 \times 10^5.

Translated by ChatGPT 5