#P5278. Arithmetic Progression Queries

    ID: 18511 Type: Default 1000ms 256MiB

Arithmetic Progression Queries

Arithmetic Progression Queries

An arithmetic wizard loves playing with arithmetic progressions. One day, he gives you a sequence of n numbers: a1, a2, …, an. He then challenges you with several operations. There are two types of operations:

  • Query Operation: Given three integers l, r, k, consider the subarray a[l...r]. After sorting this subarray in ascending order, check whether the resulting sequence forms an arithmetic progression with common difference k. (Note: A sequence with a single element is always considered an arithmetic progression.)
  • Update Operation: Change the value at a specified index. Given two integers idx and value, update a[idx] to be value.

You are required to process m operations quickly and correctly.

Input/Output Format:

The input starts with two integers n and m, where n is the length of the sequence and m is the number of operations. The next line contains n integers representing the sequence. Each of the following m lines represents an operation. For a query operation, the line starts with 1 followed by three integers l, r, k. For an update, the line starts with 2 followed by two integers idx and value.

inputFormat

The first line contains two space-separated integers n and m. The second line contains n space-separated integers a[i] (1 ≤ i ≤ n). Each of the following m lines describes an operation in one of the following formats:

  • 1 l r k — Query: check if the sorted subarray a[l...r] forms an arithmetic progression with common difference k.
  • 2 idx value — Update: change the element at position idx to value.

outputFormat

For each query operation, output a single line with either Yes if the subarray forms an arithmetic progression with the given common difference after sorting, or No otherwise.

sample

5 5
1 3 5 7 9
1 1 5 2
2 3 4
1 1 5 2
1 2 4 1
1 3 3 10
Yes

No No Yes

</p>