Balanced Seesaw Array
Time limit3sMemory limit1024 MB
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 be an array of length . is a balanced seesaw array if there exists an integer with such that .
Bob received an array as a birthday gift. He wants to know whether some non-empty subarray is a balanced seesaw array. Specifically, for given with , he asks whether is a balanced seesaw array. The elements change over time through two kinds of updates:
- Add to each of .
- Set each of to .
Bob first gives you the array. Then there are operations, each of one of the following three types.
1 l r x: add to each of .2 l r x: set each of to .3 l r: check whether is a balanced seesaw array.
Input
The first line contains two integers and , the length of the array and the number of operations. The second line contains integers . Each of the following 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
- For , you may assume that after any operation.