F. TheBigFatDuck travel in Beijing

    传统题 1000ms 256MiB

TheBigFatDuck travel in Beijing

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Background

In the 2024 postgraduate recommendation process, TheBigFatDuck, having realized its dream, left hometown Hefei for the metropolis Beijing for the further study.

Description

After a tough course, TheBigFatDuck felt hungry and he'd like to find someting to eat.

The restaurants in Beijing form a tree structure, with a total of nn restaurants indexed from 11 to nn. Each restaurant has a flavor value aia_i.

Now, TheBigFatDuck wants to know the index of the first restaurant with a flavor value greater than or equal to cc that he encounter on the path xyx \to y. It's important to note that during the process, some restaurants may update their dishes, resulting in modified flavor values.

Format

Input

The first line consists of two integers, nn and mm (1n,m200,000)(1 \le n,m \le 200,000), representing the number of nodes in a tree and the number of operations.

The next n1n-1 lines contain two integers each, uiu_i and viv_i, representing the n1n-1 edges of the tree (ui,vi)(u_i, v_i).

Following that, there is a single line with nn integers, aia_i, indicating the initial taste values of each restaurant.

The next mm lines represent the mm operations. Each line starts with an integer optopt, representing the type of operation.

  • If opt=1opt = 1, the next three integers, u,v,cu, v, c, denote that Mr. Big Duck wants to inquire the first restaurant ii on the path uvu \to v satisfied aica_i \ge c. If there is no such ii, the result of the inquiry is 1-1.
  • If opt=2opt = 2, the next two integers, x,cx, c, indicate that the restaurant with the number xx has updated its dish, and the new taste value is cc.(ax:=ca_x := c)

Output

For each operation with opt=1opt = 1, output the result of the inquiry.

Sample

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

image

Limitation

1s,128MB


In the end, TheBigFatDuck stopped in front of a LaoxiangJi.

"I still miss the familiar taste of Fei Xi Lao Mu Chicken Soup. Perhaps I'm longing for my college days."

"Now that I've finally achieved my dream, I've lost youthful sight of the past days. Was it worth it?"

Suddenly, TheBigFatDuck realized that he had nothing to commemorate or regret because TheHamster even did not exist. It was merely a figment of his imagination, even though it provided him encouragement and support, urging him to make changes.

"Perhaps I should say thank you to TheHamster, but regardless, it's time to wake up. This is the path I have chosen, and I must keep on going."

2023安徽大学ICPC集训队排位选拔赛 - Round1

未参加
状态
已结束
规则
ACM/ICPC
题目
6
开始于
2023-6-3 8:00
结束于
2023-6-3 12:00
持续时间
4 小时
主持人
参赛人数
29