问题 A: Xcellent Tree Query Problem

内存限制:512 MB 时间限制:8 S
题面:传统 评测方式:文本比较 上传者:
提交:1 通过:0

题目描述

Given a tree consisting of n nodes. Each node initially have a color c_i.

You are given mm commands, each of them is one of the follows:

  • x  Cut the x-th edge of the input.
  • x l r v For every y currently connected with x (that is, no edges lying on the simple path from x to y is cut), if lc_yr, set c_y to v.
  • x l Count the number of y currently connected with xx, that satisfy lc_yr.

输入格式

The first line of the input contains two integers n(1n10^5) and m (1m5×10^5).

The second line contains integers c1,c2,,cn (1cin).

Each of the following n - 1 lines contains two integers u, v (1u,vn,u!=v) - an edge of the tree.

Each of the following m lines contains one of the three commands listed above.

It's guaranteed that no edges is cut twice or more.

It's also guaranteed that in command of type 2 and 3,  1lrn 1x,vn.

输出格式

For every command of type 3, output the answer in a single line.

输入样例 复制

10 19
1 2 3 4 5 6 7 8 9 10
1 2
2 3
3 4
4 5
4 6
5 7
5 8
1 9
9 10
3 4 1 10
3 8 3 4
2 9 9 10 1
3 4 1 10
3 2 8 10
1 4
3 8 1 10
3 7 7 8
2 5 5 7 9
3 7 9 10
2 1 1 2 3
3 1 3 3
1 1
3 1 3 3
2 10 3 9 4
3 1 4 4
2 3 3 5 9
3 3 6 10
3 3 6 6

输出样例 复制

10
2
10
1
3
2
2
5
3
3
4
1

分类标签