#P6812. Pioneer Sequence Query

    ID: 20019 Type: Default 1000ms 256MiB

Pioneer Sequence Query

Pioneer Sequence Query

You are given a sequence of n integers a1, a2, …, an. A sequence a is said to be a pioneer if for every proper suffix of the sequence, a is worse than that suffix. Formally, for two sequences a and b with lengths n and m respectively, if

imin(n,m),aibi,\forall\, i \le \min(n,m),\quad a_i \le b_i,

then we say that a is worse than b. In particular, a sequence a is a pioneer if for every suffix b of a (where b = a[i...n] for some 2 \le i \le n), we have

$$\forall\, 1 \le j \le n-i+1,\quad a_j \le a_{i+j-1}. $$

This condition is equivalent to the subarray being non-decreasing (i.e. for any i < j, we have ai \le aj).

You will be given k operations to perform on the sequence. The operations are of the following two types:

  • 1 l r x: Add integer x to every element in the subarray [l, r].
  • 2 l r: Query whether the subarray [l, r] is pioneer (i.e. non-decreasing).

Note: The indices are 1-indexed.

inputFormat

The first line contains two integers n and k representing the length of the sequence and the number of operations, respectively. The second line contains n integers representing the initial sequence a.

Each of the next k lines contains an operation in one of the following formats:

  • 1 l r x
  • 2 l r

It is guaranteed that all values are integers.

outputFormat

For each query operation (of type 2), output a single line containing Yes if the specified subarray is pioneer (i.e. non-decreasing), otherwise output No.

sample

5 5
1 2 3 2 4
2 1 3
1 4 5 1
2 4 5
1 2 3 -2
2 1 5
Yes

Yes No

</p>