#P4690. Galgame Crash: Data Structure Challenge

    ID: 17935 Type: Default 1000ms 256MiB

Galgame Crash: Data Structure Challenge

Galgame Crash: Data Structure Challenge

You are provided with a sequence (a_1, a_2, \ldots, a_n) of length (n) and (m) operations. Initially, the sequence is given and then, you need to process (m) operations on it. There are two types of operations:

  1. Update operation: Given integers (l, r, x), assign (a_i = x) for all (l \le i \le r).
  2. Query operation: Given integers (l, r), determine how many distinct numbers appear in the subarray (a_l, a_{l+1}, \ldots, a_r).

Note: The indices are 1-indexed. Use ( [l, r] ) to represent the range from (l) to (r), inclusive.

inputFormat

The first line contains two integers (n) and (m), representing the length of the sequence and the number of operations respectively. The second line contains (n) integers, representing the initial sequence (a_1, a_2, \ldots, a_n). The following (m) lines each represent an operation. An operation is given in one of the following formats:

  • For an update operation: 1 l r x
  • For a query operation: 2 l r

It is guaranteed that all indices satisfy (1 \leq l \leq r \leq n).

outputFormat

For each query operation, output a single line containing one integer — the number of distinct numbers in the specified range.

sample

5 5
1 2 3 4 5
2 1 5
1 2 4 2
2 1 5
1 1 3 3
2 3 5
5

3 3

</p>