#K80917. Query Operations on Purchased Items

    ID: 35637 Type: Default 1000ms 256MiB

Query Operations on Purchased Items

Query Operations on Purchased Items

You are given an array of integers representing the items purchased in order. You need to process several queries on this array. There are three types of queries:

  • Type 1: 1 u t – Replace the u-th item in the array with t.
  • Type 2: 2 u k – Add an integer k to the u-th item.
  • Type 3: 3 l r – Count the number of unique items between indices l and r (both inclusive). Mathematically, if S is the set of items in the range, you must output \( |S| \).

Perform the queries in the order given. For queries of type 3, output the result on stdout. All queries use 1-indexed positions.

inputFormat

The input is read from standard input (stdin) and has the following format:

N
a1 a2 ... aN
Q
query1
query2
...
queryQ

Here, N is the number of purchased items, followed by N space-separated integers. Then Q is the number of queries, followed by Q queries. Each query is represented by space-separated integers.

outputFormat

For every query of type 3, output the result (the count of unique items in the interval) on a new line to standard output (stdout).

## sample
5
1 2 2 1 3
4
3 1 5
1 2 4
3 1 5
2 3 10
3

4

</p>