| UFBA Selection Contest 2026 |
|---|
| Finished |
During a GruPro meeting at UFBA, an unfortunate joke started spreading through a friendship network. The network forms a tree with $$$N$$$ students, numbered from $$$1$$$ to $$$N$$$.
Each student is currently in one of two moods:
When a story travels through the unique simple path between two students, every suspicious student on that path would react. However, there is an important Bahian rule: once someone says "lá ele!", everyone in the same consecutive suspicious stretch becomes protected, so no extra "lá ele!" is needed until the path reaches a calm student again.
As the meeting goes on, people may change their mood after hearing new context, remembering an older joke, or deciding that the conversation was actually harmless. Because of that, the current mood of a student is not fixed forever.
You must process two types of operations:
The first line contains two integers $$$N$$$ and $$$Q$$$ ($$$2 \leq N \leq 2 \times 10^{5}$$$, $$$1 \leq Q \leq 2 \times 10^{5}$$$).
The second line contains $$$N$$$ integers $$$B_1, B_2, \dots, B_N$$$ ($$$0 \leq B_i \leq 1$$$), where $$$B_i$$$ is the initial mood of student $$$i$$$.
Each of the next $$$N-1$$$ lines contains two integers $$$a$$$ and $$$b$$$ ($$$1 \leq a, b \leq N$$$, $$$a \neq b$$$), indicating that students $$$a$$$ and $$$b$$$ are connected. It is guaranteed that these edges form a tree.
Each of the next $$$Q$$$ lines describes one operation in one of the following formats:
For each operation of type 2, output a single integer: the number of times "lá ele!" is said along the queried path.
6 61 0 1 0 1 11 22 33 44 54 62 1 52 3 61 4 12 3 61 2 12 1 5
3 2 1 1
5 50 0 0 0 01 21 33 43 52 2 41 3 12 2 41 1 12 2 4
0 1 1
| Name |
|---|


