report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Pair - FlandreOJ: Flandre 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 ```
Square root decomposition
Frequency
Tree query
Inversions query
Nearest vertex
Dominating color
String occurences 3
Inversions query 2
Pair
Sparse update
Tree
Range query
String concatenation
Subarray distance
Chameleon
Knapsack
Bit counting
Subsequence queries
Sub-subsequence
Delete numbers
Mode
Marisa is happy
Inversions query 3
Upperbound
23 path
Yet another square root decomposition problem
Marisa plays poker
Wonderful world
Topic
Binary search
Data structure
Rating 1700
Source Codeforces
Solution (0) Solution