report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Upperbound - FlandreOJ: Flandre Online Judge

Upperbound

Time limit: 1500 ms
Memory limit: 256 MB
Given an array $A$ of $n$ elements, there are $q$ queries, each falling into one of two types: - `1 i x`: Assign the value $x$ to $A_i$. - `2 l r x`: Count the number of pairs $(i, j)$ such that $l \le i \le j \le r$ and the maximum value in the subarray $A_{i...j}$ does not exceed $x$. Answer the queries of type $2$. ### Input - The first line contains two integers $n, q$. - The second line contains $n$ integers $A_i$. - The next $q$ lines each contain a query in the specified format. ### Output - Print an integer as the answer for each query of type $2$. ### Constraints - $1 \le n,q \le 10^5$. - $1 \le A_i,x \le 10^9$. - $1 \le l \le r \le n$. ### Example Input: ``` 6 6 1 1 4 5 1 4 1 1 4 2 1 4 2 2 1 1 4 2 1 5 4 1 5 4 2 3 3 3 ``` Output: ``` 1 1 7 0 ```
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
Data structure
Rating 2300
Solution (0) Solution