#P3979. 遥远的国度
遥远的国度
Description
zcwwzdjn is hunting down zhx, and zhx has fled to a distant kingdom. When zcwwzdjn is about to enter the distant kingdom to continue the pursuit, the guardian RapiD blocks his way. He must complete a task before he can enter the distant kingdom and continue the chase.
Here is the problem: the distant kingdom has cities. These cities are connected by some roads and they form a tree. The kingdom has a capital, and we can regard this capital as the root of the whole tree; however, the capital may change to another city at any time. Each city has a defense value; the -th city's defense value is . Sometimes RapiD will set the defense values of all cities on the path between two cities to a certain value.
RapiD wants to know, at some moment, if we regard the capital as the root of the whole tree, then what is the minimum defense value among all cities in the subtree rooted at some city.
Since RapiD cannot solve this, he stopped zcwwzdjn hoping he could help. But zcwwzdjn still needs to hunt down zhx, so this important problem has been handed over to you.
Input Format
Line : two integers , representing the number of cities and the number of operations.
Lines to : each line contains two integers , meaning there is a road between city and city .
Line : integers; the -th integer is the initial defense value of the -th city.
Line : one integer , meaning the initial capital is .
Lines to : first there is an integer .
- If , then there is an integer , meaning the capital is updated to .
- If , then there are three integers , meaning the defense values of all cities on the path are set to .
- If , then there is an integer , meaning you need to query the minimum defense value in the subtree rooted at city (with the current capital regarded as the root of the whole tree).
Output Format
For each operation, output one line containing the minimum defense value in the corresponding subtree.
3 7
1 2
1 3
1 2 3
1
3 1
2 1 1 6
3 1
2 2 2 5
3 1
2 3 3 4
3 1
1
2
3
4
Hint
For of the testdata, .
For another of the testdata, , and updates are guaranteed to be point updates.
For another of the testdata, , and the tree is guaranteed to be a chain.
For another of the testdata, , and there are no operations that change the capital.
For of the testdata, $1 \leq n\le 100000,1 \leq m \le 100000,0<val_i<2^{31}$.
Translated by ChatGPT 5
京公网安备 11011102002149号