8675: Cut

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:3 通过:1

题目描述


Greninja is helping Zygarde cut trees.

There are nnn trees in the forest of Kalos. The height of the iii-th tree is aia_iai. Since no two trees are exactly same, a1,a2,…,ana_1,a_2, \ldots, a_na1,a2,,an is a permutation of 1,2,…,n1,2,\ldots,n1,2,,n. Zygarde wants Greninja to do mmm operations of three following types:

  1. Sort al,al+1,…,ara_l,a_{l+1},\ldots,a_ral,al+1,,ar in increasing order.
  2. Sort al,al+1,…,ara_l,a_{l+1},\ldots,a_ral,al+1,,ar in decreasing order.
  3. Find the maximum positive integer kkk that exists kkk integers l≤b1<b2<⋯bk≤rl \le b_1 < b_2 <\cdots b_k \le rlb1<b2<bkr satisfy abi≢abi+1(mod2)a_{b_i} \not \equiv a_{b_{i+1}} \pmod 2abiabi+1(mod2) for 1≤i<k1 \le i < k1i<k.

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

输入格式


The first line contains two integers n,mn,mn,m (1≤n,m≤1051 \le n,m \le 10^51n,m105), denoting the number of trees and the number of operations.
The second line contains nnn integers a1,a2,…,ana_1,a_2, \ldots, a_na1,a2,,an (1≤ai≤n1 \le a_i \le n1ain), denoting the initial height of trees. It's guaranteed that a1,a2,…,ana_1,a_2, \ldots, a_na1,a2,,an is a permutation of 1,2,…,n1,2,\ldots, n1,2,,n.
For the iii-th line in the following mmm lines, there are three integers oi,li,rio_i,l_i,r_ioi,li,ri (1≤oi≤3,1≤li≤ri≤n1 \le o_i \le 3, 1 \le l_i \le r_i \le n1oi3,1lirin), denoting the type of the iii-th operation and the range of the iii-th operation.

输出格式


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

输入样例 复制

3 3
1 3 2
3 1 3
1 2 3
3 1 3

输出样例 复制

2
3

数据范围与提示

链接:https://ac.nowcoder.com/acm/contest/33186/F
来源:牛客网

In the first example, the initial height of trees is [1,3,2][1,3,2][1,3,2]. In the first operation, the maximum kkk is 222, since a1≢a3(mod2)a_1 \not \equiv a_3 \pmod 2a1a3(mod2) and a1≡a2(mod2)a_1 \equiv a_2 \pmod 2a1a2(mod2) (so kkk cannot be 333). After the second operation, the height of trees becomes [1,2,3][1,2,3][1,2,3]. In the third operation, the maximum kkk is 333, since a1≢a2(mod2)a_1 \not \equiv a_2 \pmod 2a1a2(mod2) and a2≢a3(mod2)a_2 \not \equiv a_3 \pmod 2a2a3(mod2).

分类标签