#P10680. [COTS 2024] 双双决斗 Dvoboj
[COTS 2024] 双双决斗 Dvoboj
Background
Translated from Izborne Pripreme 2024 (Croatian IOI/CEOI Team Selection) D1T1. .
Two pharaonic yellow lines turned into an eye...
Problem Description
Jusuf has cards, numbered from to from left to right. The power of the -th card is . Since Jusuf is about to take part in a contest, he wants to imagine battles in his mind. Sometimes, he also changes the power values of the cards. In total, Jusuf will perform operations, and each operation is one of the following two types:
-
1 i r: Jusuf sets the power of the card at position to , i.e. . -
2 l k: Jusuf imagines a battle in his mind. This battle uses cards from the -th card to the -th card, i.e. cards .The battle will last for rounds. In each round, Jusuf groups the -th and the -th cards together (for example, the -st and the -nd cards form a group).
For each group of cards, Jusuf compares their powers. Suppose the powers of the two cards are and . The card with the larger power wins, and the winning card’s power becomes , while the other card is removed. In particular, if , then the result of this battle cannot be determined: one card will win at random, and its power becomes .
Note that after rounds, only one card will remain. Jusuf wants to know the power of this remaining card.
Since Jusuf is only imagining the battle, the number of cards will not actually change, and will not change either.
Input Format
The first line contains two positive integers , as described in the statement.
The second line contains integers. The -th integer represents .
The next lines each contain positive integers, describing an operation.
Output Format
For each operation of type , output one integer per line, representing the required power.
5 3
4 8 2 0 7
2 1 2
1 1 9
2 2 1
2
6
8 6
1 2 3 4 5 6 7 8
2 1 3
1 4 1
1 7 3
2 1 3
1 2 100
2 2 2
0
3
93
9 5
1 0 2 0 4 1 3 2 8
2 2 3
2 1 3
1 5 1
1 6 4
2 4 2
2
1
0
Hint
Sample Explanation
For the first query of sample , we have:
$$(\bold{\textcolor{red}{4}},8,\bold{\textcolor{red}{2}},0)\to (\bold{\textcolor{red}{4}},2)\to(2)$$For the second query of sample , we have:
Constraints
For of the testdata, it is guaranteed that:
- , ;
- ;
- , ;
- , 。
| Subtask ID | Points | Constraints |
|---|---|---|
| No modification operations | ||
| No additional constraints |
Translated by ChatGPT 5