report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Wonderful world - MarisaOJ: Marisa Online Judge

Wonderful world

Time limit: 1000 ms
Memory limit: 500 MB
Marisa has given you a sequence of length $n$, with $m$ operations: 1. Decrease by $x$ the numbers greater than $x$ in the interval $[l,r]$. 2. Count the occurrences of $x$ in the interval $[l,r]$. ### Input The first line contains two integers $n,m$. The second line contains $n$ integers representing the sequence $a$. The next $m$ lines each contain four integers: - `1 l r x`: Decrease by $x$ the numbers greater than $x$ in the interval $[l,r]$. - `2 l r x`: Count the occurrences of $x$ in the interval $[l,r]$. ### Output For each query, output an integer representing the answer. ### Constraints - $1 \le l \le r \le n $ - $ x, n, m, a_i \le 10^5 $ ### Example Input ``` 5 6 1 5 5 5 8 2 2 5 5 1 2 4 3 2 2 5 2 2 2 5 5 1 3 5 1 2 1 5 1 ``` Output ``` 3 3 0 3 ```
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 2400
Source ynoi
Solution (1) Solution