selction
题号:NC237452
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

There is a contest with n participants.

During the contest, all participants will stand in a line. Every participant has a level a_i

In the i-th turn, number all participants in the order. Then participants numbered between l_i,r_i will have a competition and the one with the maximum level will win. If two or more participants have the same maximum level, then only one of them may win. Then all losers will get out of the line, while others stand in the same order.

Now n-1 participants have stood in a line. m events follow:

1. A new turn for  l_i,r_i has been added to the schedule.

2. Query: if the last participant has a level of x and he/she can choose the position to stand at, how many turns he/she can definitely win.


Note that:

1. If the last participant is not in , then he/she is never considered to win in this turn.

2. If in a turn there are two or more participants with the same maximum level, the last participant may lose (not definitely win).



输入描述:

The first line contains two integers n,m (  ).

The second line contains n-1 integers ( ), describing the level of the n-1 participants.

Then m line, each line beginning with an integer opt ( ).

If , then two integers l,r,describing a new turn ( ).

If , then an integers x, describing a query ( ).

It is guaranteed that in each turn there is at least r participants left.

输出描述:

For every query, output one line containing the position where the number of turns the last participant can definitely win is maximized. If two or more positions satisfy the condition, output the minimum one.
示例1

输入

复制
5 8
2 1 3 5
1 2 4
1 1 2
1 1 2
2 4
2 1
2 2
2 3
2 5

输出

复制
2
1
1
1
2