Z1932 树上路径

 

# Description
给你一棵树,树上每个点都有其color

现在问你对于每种color,有多少种简单路径经过它

# Format

## Input
一行给出N

第二个N个数字,代表每个点的color

接下来N-1描述这个树

N<=2e5

color<=2e5


## Output
如题

# Samples

```input1
3
1 2 1
1 2
2 3
```

```output1
5
4
0
```


Hint

对于第1种color,路径[1,1],[1,2],[1,3],[2,3],[3,3]都有第1种color

对于第2种color,路径[1,2],[1,3],[2,2],[2,3]都有第2种color

 

 

https://www.acwing.com/file_system/file/content/whole/index/content/5721964/

 

https://www.cnblogs.com/heyuhhh/p/12911806.html

 

posted @ 2023-02-13 11:44  我微笑不代表我快乐  阅读(14)  评论(0编辑  收藏  举报