|
||||||||||
A. Xcellent Tree Query ProblemTime Limit: 8000/4000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 129 Accepted Submission(s): 57 Problem Description Given a tree consisting of $n$ nodes. Each node initially have a color $c_i$. You are given $m$ commands, each of them is one of the follows: - $1\ x$: Cut the $x$-th edge of the input. - $2\ 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 $l\le c_y\le r$, set $c_y$ to $v$. - $3\ x\ l\ r$: Count the number of $y$ currently connected with $x$, that satisfy $l\le c_y\le r$. Input The first line of the input contains two integers $n$ ($1\leq n\leq 10^5$) and $m$ ($1\leq m\leq 5\times 10^5$). The second line contains $n$ integers $c_1, c_2, \dots, c_n$ ($1\leq c_i\leq n$). Each of the following $n - 1$ lines contains two integers $u, v$ ($1 \le u, v \le n$, $u \ne 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$, $1\le l\le r\le n$, $1\le x, v\le n$. Output For every command of type $3$, output the answer in a single line. Sample Input
Sample Output
Source | ||||||||||
|