406476: GYM102419 I Another Query Problem

Memory Limit:512 MB Time Limit:5 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Another Query Problemtime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

Given the length $$$n$$$ of an array $$$A$$$ such that all $$$A_i$$$ $$$=$$$ $$$0$$$ for all $$$1 \leq i \leq n$$$.

You need to answer $$$q$$$ queries of two types:

1) $$$1$$$ $$$l$$$ $$$r$$$ print 1 if all values of $$$A_i$$$, such that $$$l \leq i \leq r$$$, are equal.

2) $$$2$$$ $$$l$$$ $$$r$$$ $$$a$$$ $$$b$$$ update the range $$$l$$$ $$$r$$$ with the arithmetic progression $$$a + b*(i - l)$$$.

For example if $$$l=2$$$, $$$r=5$$$, $$$a=4$$$, and $$$b=3$$$ then:

$$$A_2 = A_2 + 4$$$

$$$A_3 = A_3 + 4 + 3$$$

$$$A_4 = A_4 + 4 + 2*3$$$

$$$A_5 = A_5 + 4 + 3*3$$$

Input

First line contains two integers $$$n$$$ and $$$q$$$ $$$(1 \leq n,q \leq 2*10^5)$$$.

Each of the next q lines follow one of two formates:

1) $$$1$$$ $$$l$$$ $$$r$$$ $$$(1 \leq l \leq r \leq n)$$$

2) $$$2$$$ $$$l$$$ $$$r$$$ $$$a$$$ $$$b$$$ $$$(-10^8 \leq a,b \leq 10^8)$$$

Output

For each query of the second type print $$$1$$$ if the range is made up of the same value and $$$0$$$ if it's not.

ExampleInput
5 3
2 1 3 4 1
1 1 3
1 4 5
Output
0
1

Source/Category

加入题单

上一题 下一题 算法标签: