coderforce Educational Codeforces Round 6 E.New Year Tree
来源:互联网 发布:windows ssh下载文件 编辑:程序博客网 时间:2024/06/16 09:46
The New Year holidays are over, but Resha doesn't want to throw away the New Year tree. He invited his best friends Kerim and Gural to help him to redecorate the New Year tree.
The New Year tree is an undirected tree with n vertices and root in the vertex1.
You should process the queries of the two types:
- Change the colours of all vertices in the subtree of the vertex v to the colour c.
- Find the number of different colours in the subtree of the vertex v.
The first line contains two integers n, m (1 ≤ n, m ≤ 4·105) — the number of vertices in the tree and the number of the queries.
The second line contains n integers ci (1 ≤ ci ≤ 60) — the colour of thei-th vertex.
Each of the next n - 1 lines contains two integersxj, yj (1 ≤ xj, yj ≤ n) — the vertices of thej-th edge. It is guaranteed that you are given correct undirected tree.
The last m lines contains the description of the queries. Each description starts with the integertk (1 ≤ tk ≤ 2) — the type of thek-th query. For the queries of the first type then follows two integersvk, ck (1 ≤ vk ≤ n, 1 ≤ ck ≤ 60) — the number of the vertex whose subtree will be recoloured with the colour ck. For the queries of the second type then follows integervk (1 ≤ vk ≤ n) — the number of the vertex for which subtree you should find the number of different colours.
For each query of the second type print the integer a — the number of different colours in the subtree of the vertex given in the query.
Each of the numbers should be printed on a separate line in order of query appearing in the input.
7 101 1 1 1 1 1 11 21 31 43 53 63 71 3 22 11 4 32 11 2 52 11 6 42 12 22 3
234512
23 301 2 2 6 5 3 2 1 1 1 2 4 5 3 4 4 3 3 3 3 3 4 61 21 31 42 52 63 73 84 94 104 116 126 137 147 157 168 178 1810 1910 2010 2111 2211 232 12 52 62 72 82 92 102 112 41 12 11 13 11 14 11 15 11 16 11 17 11 18 11 19 11 20 11 21 11 22 11 23 12 12 52 62 72 82 92 102 112 4
613321235512211123
- coderforce Educational Codeforces Round 6 E.New Year Tree
- Educational Codeforces Round 6 E. New Year Tree
- Educational Codeforces Round 6 E. New Year Tree CF620E
- Educational Codeforces Round 6 E. New Year Tree(DFS序+线段树)
- Educational Codeforces Round 6 E. New Year Tree(dfs序线段树)
- Educational Codeforces Round 6 E. New Year Tree(DFS序+线段树)
- 【Educational Codeforces Round 6E】【线段树 dfs序】New Year Tree 子树颜色修改子树颜色数
- Codeforces 620 E. New Year Tree
- Codeforces 620E New Year Tree
- New Year Tree CodeForces
- New Year Tree CodeForces
- New Year Tree CodeForces
- Codeforces edu 6. E New Year Tree 图论 线段树
- CodeForces 620E New Year Tree(线段树)
- Codeforces 620E New Year Tree (哈希 + 线段树)
- CodeForces 620 E.New Year Tree(线段树)
- CodeForces 620E New Year Tree 线段树
- Educational Codeforces Round 21 A. Lucky Year
- 人情世故!决定人生是飞黄腾达,还是穷困潦倒?
- [CSAPP] 信息的表示和处理(一)
- 安卓关键字——implements
- 每日一参数--innodb_old_blocks_pct、innodb_old_blocks_time理解
- Restful风格自学浅读
- coderforce Educational Codeforces Round 6 E.New Year Tree
- Android onSaveInstanceState()和onRestoreInstanceState()调用时机
- 关于SpringMVC的DispatcherServlet配置
- 安卓关键字——@override
- Ajax技术中的优越性和局限性
- web开发中遇到request.getremoteaddr() 0:0:0:0:0:0:1
- HTTP协议简介
- Memory Management (3) DXE 概括
- mac版MySQL初始密码 root