PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000019. Tần suất giá trị trong đoạn có cập nhật (Point Set Range Frequency)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tần suất giá trị trong đoạn có cập nhật (Point Set Range Frequency)
Point Set Range Frequency
Source: Library Checker
Version: Phuoc Hung OJ Extended
Problem Statement
You are given a nonnegative integer array of length , indexed from . Process operations in order:
0 k v: assign .1 l r x: count occurrences of in the half-open interval , i.e. at indices through .
An empty interval has answer . The array itself may be empty when ; in that case updates are not permitted.
Input
The first line contains . The next line holds the initial values (empty if ). Each of the following lines is either 0 k v or 1 l r x.
Output
For every operation of type 1, print the number of occurrences of in the queried interval.
Subtasks
- Subtask 1 (10 points): ; ; ; updates require ; queries require . Both and are allowed.
- Subtask 2 (20 points): ; ; ; updates require ; queries require . Both and are allowed.
- Subtask 3 (30 points): ; ; ; updates require ; queries require . Both and are allowed.
- Subtask 4 (40 points): ; ; ; updates require ; queries require . Both and are allowed.
Examples
Input
5 6
3 7 1 2 1
1 1 5 1
1 3 3 0
1 0 4 3
0 1 1
1 0 5 1
1 0 5 123456789
Output
2
0
1
3
0
Explanation
The first query examines and finds two occurrences of . The interval is empty. After 0 1 1, the array becomes , which contains three ones.