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

题目描述

Greninja is helping Zygarde cut trees.

There are n trees in the forest of Kalos. The height of the i-th tree is a_i. Since no two trees are exactly same, is a permutation of . Zygarde wants Greninja to do m operations of three following types:

  1. Sort in increasing order.
  2. Sort in decreasing order.
  3. Find the maximum positive integer k that exists k integers satisfy for .

Without Battle Bond, Greninja cannot do these operations by itself. Can you help him?

输入描述:

The first line contains two integers n,m (), denoting the number of trees and the number of operations.

The second line contains n integers (), denoting the initial height of trees. It's guaranteed that is a permutation of .

For the i-th line in the following m lines, there are three integers o_i,l_i,r_i (), denoting the type of the i-th operation and the range of the i-th operation.

输出描述:

For each operation in type 3, print an integer in a single line, denoting the answer of this operation.
示例1

输入

复制
3 3
1 3 2
3 1 3
1 2 3
3 1 3

输出

复制
2
3
示例2

输入

复制
10 2
1 4 3 5 6 2 9 8 10 7
2 1 5
3 1 6

输出

复制
5
示例3

输入

复制
10 6
1 4 3 5 6 2 9 8 10 7
2 1 5
3 1 6
1 2 6
3 1 7
2 1 10
3 1 10

输出

复制
5
6
10
示例4

输入

复制
10 4
1 4 3 5 6 2 9 8 10 7
2 1 5
3 1 6
1 3 4
3 1 6

输出

复制
5
5
示例5

输入

复制
10 4
6 4 3 2 10 7 8 1 5 9
1 6 8
1 8 8
3 5 9
3 6 7

输出

复制
4
1

备注:

In the first example, the initial height of trees is . In the first operation, the maximum k is 2, since  and  (so k cannot be 3). After the second operation, the height of trees becomes . In the third operation, the maximum k is 3, since  and .