#P1803. E - Count Descendants

E - Count Descendants

题目描述

PDF

输入格式

As shown in the pdf.

输出格式

As shown in the pdf.

样例

7 
1 1 2 2 4 2 
4 
1 2 
7 2 
4 1 
5 5 

3 
1 
0 
0 

提示

AISing Programming Contest 2021 by 杨鑫