当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6615:Colored Tree

题目描述
There is a tree with vertex 1 as a root. All vertices of the tree are colored.
Your task is to determine the number of sub-trees with exactly k distinct colors.
There are two types of queries.
1 u c : paint vertex u with color c.
2 k : answer the query.
输入解释
The first line of input contains an integer T (1 <= T <= 5) denoting the number of test cases.
The first line of each test case contains two integers N and Q (1 <= N, Q <= 100000), the number of vertices in the given tree and the number of queries respectively. Each of the next N - 1 lines contains two integers u and v, representing that there exists an edge between vertex u and v.
The next line contains N space-separated integers and the i-th integer denotes the color of vertex i.
Then Q lines followed and each line consists of one of two types of queries.
输出解释
For each query of type 2, output the answer in one line.
输入样例
1
3 2
1 2
2 3
1 2 3
1 2 1
2 2
输出样例
2
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6615

最后修改于 2020-10-25T23:32:49+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
14000/7000MS(Java/Others) 524288/524288K(Java/Others)