#C2318. Array Update and Query
Array Update and Query
Array Update and Query
You are given an array of \(n\) integers and \(q\) queries. The queries can be of two types:
- Update Query:
1 x y
— Update the element at index \(x\) to \(y\). - Range Query:
2 l r k
— Count the number of occurrences of \(k\) in the subarray from index \(l\) to \(r\) (inclusive).
Indices are 1-indexed. Your task is to perform the queries sequentially and for each range query, output the corresponding count.
Note: The input and output should be handled using standard input (stdin) and standard output (stdout).
inputFormat
The first line contains two integers \(n\) and \(q\), where:
- \(n\) is the number of elements in the array.
- \(q\) is the number of queries.
The second line contains \(n\) space-separated integers denoting the elements of the array.
The following \(q\) lines each describe a query in one of the following formats:
1 x y
— Update the \(x\)th element in the array to \(y\).2 l r k
— Output the count of integer \(k\) in the subarray from index \(l\) to \(r\) (inclusive).
outputFormat
For each query of type 2
, output a single integer representing the answer on a new line.
5 5
1 2 3 4 5
2 1 5 3
1 3 6
2 1 5 3
2 2 4 2
1 5 2
1
0
1
</p>