This page is still under construction.

Parts of this page are still being built. What you see may change.

Balanced Seesaw Array

Time limit3sMemory limit1024 MB

Summary
Given an array with range add and range assign updates, answer whether a queried subarray is a balanced seesaw array.
Level

Hard8 of 10

Topics
Segment tree, Math, Prefix sum
Solved
No attempts yet

Problem

Bob likes playing on a seesaw. He thinks it is really fun when the seesaw is balanced, meaning it does not tilt left or right. After playing, Bob thinks about a problem involving balanced seesaw arrays.

Let A=[a1,a2,…,am]A = [a_1, a_2, \dots, a_m] be an array of length mm. AA is a balanced seesaw array if there exists an integer kk with 1≤k≤m1 \le k \le m such that ∑i=1m(i−k)ai=0\sum_{i=1}^{m}(i-k)a_i = 0.

Bob received an array A=[a1,a2,…,an]A = [a_1, a_2, \dots, a_n] as a birthday gift. He wants to know whether some non-empty subarray is a balanced seesaw array. Specifically, for given (ℓ,r)(\ell, r) with 1≤ℓ≤r≤n1 \le \ell \le r \le n, he asks whether [aℓ,…,ar][a_\ell, \dots, a_r] is a balanced seesaw array. The elements change over time through two kinds of updates:

  1. Add xx to each of aℓ,…,ara_\ell, \dots, a_r.
  2. Set each of aℓ,…,ara_\ell, \dots, a_r to xx.

Bob first gives you the array. Then there are qq operations, each of one of the following three types.

  • 1 l r x: add xx to each of aℓ,…,ara_\ell, \dots, a_r.
  • 2 l r x: set each of aℓ,…,ara_\ell, \dots, a_r to xx.
  • 3 l r: check whether [aℓ,…,ar][a_\ell, \dots, a_r] is a balanced seesaw array.

Input

The first line contains two integers nn and qq, the length of the array and the number of operations. The second line contains nn integers aia_i. Each of the following qq lines describes one operation as defined above.

Output

For each operation of type 3, print Yes if the subarray is a balanced seesaw array, otherwise print No.

Constraints

  • 1≤n≤1000001 \le n \le 100000
  • 1≤q≤12000001 \le q \le 1200000
  • −1000≤ai≤1000-1000 \le a_i \le 1000
  • −10000≤x≤10000-10000 \le x \le 10000
  • For 1≤i≤n1 \le i \le n, you may assume that ∣ai∣≤1.5×109|a_i| \le 1.5 \times 10^9 after any operation.
  • 1≤ℓ≤r≤n1 \le \ell \le r \le n

Examples1

  1. Example 1

    Input
    3 6
    1 2 3
    3 1 1
    3 1 3
    1 1 1 2
    3 1 3
    2 2 2 0
    3 2 3
    
    Expected output
    Yes
    No
    Yes
    Yes