Skip to content

Editorial for Phân chia cây

Phân chia cây

Problem code: olpicpc040c10b Group: Uncategorized Points: 1,500 pointspartial
Limits
1.0 s, 256 MB
AC rate
30.6%
Solvers
17
Read the editorial only when you are stuck, and do not copy code from it. Please respect the problem author and the editorialist: submitting an official solution before solving the problem yourself is a bannable offence.

Với mỗi đường đi v_1,v_2,...,v_k, có tối đa 1 đỉnh lá của cây, khi đó đỉnh lá chỉ có thể nằm ở vị trí cuối cùng của đường đi (tương ứng đỉnh v_k). Ngoài ra, mỗi đỉnh lá thuộc chính xác một đường đi. Vì vậy, đáp án bài toán là số đỉnh lá (ngoại trừ đỉnh gốc) của cây.

Độ phức tạp: O(N)

Comments