Pair - MarisaOJ: Marisa Online Judge

Pair

Time limit: 4000 ms
Memory limit: 256 MB
Given an array $A$ of $n$ integers and $q$ queries of either forms: - `1 l r x`: increase each element $A_l,A_{l+1},...,A_r$ by $x$. - `2 x`: find the maximum $j-i$ that $A_i=A_j=x$. ### Input - The first line contains two integers $n,q$. - The second line contains $n$ integers $A_i$. - The next $q$ lines, each line contains a query of the above forms. ### Output - Print an integer, which is the answer for each query of type $2$. If there is no answer, print `-1`. ### Constraints - $1 \le n,q \le 10^5$. - $1 \le l, r \le n$. - $1 \le A_i,x \le 2 \times 10^9$. ### Example Input: ``` 2 3 1 2 1 2 2 1 2 3 2 4 ``` Output: ``` 0 -1 ```