Under construction

Still being built. Things may change

Nolik and the Game

Time limit2sMemory limit1024 MB

Summary
Given n colored cubes with point color updates, answer each range query with the maximum number of distinct colors in any length-k window inside the query range.
Level

Hard8 of 10

Topics
Segment tree, Sliding window, Hash map
Solved
No attempts yet

Statement

Nolik found an interesting game on Dim Dimych's phone. Its creators meant it to train reaction speed and attentiveness. For Dim Dimych, it is too hard.

The game works as follows. nn colored cubes stand in a row on the screen. At some moments the colors of some cubes change. At other times the game asks a question: it gives an interval [l…r][l \dots r] (1≤l≤r≤n1 \le l \le r \le n), and the player must answer with the maximum number of distinct colors on a segment of length kk contained in [l…r][l \dots r]. The number kk is set at the start of the game and stays fixed throughout. Your goal is to answer every question correctly.

You play the programmer of this game and compute the correct answers to all questions.

Input

The first line contains three integers nn, mm, kk (1≤n≤1051 \le n \le 10^5, 1≤m≤1051 \le m \le 10^5, 1≤k≤n1 \le k \le n): the number of cubes, the number of events, and the segment length. The second line contains nn integers aia_i (1≤ai≤1061 \le a_i \le 10^6), the initial colors of the cubes.

Each of the next mm lines describes one event:

  • 1 i x: change the color of the ii-th cube to xx (1≤i≤n1 \le i \le n, 1≤x≤1061 \le x \le 10^6).
  • 2 l r: answer the question for the interval [l…r][l \dots r], where r−l+1≥kr - l + 1 \ge k.

Output

For each event of type 2, print the answer on its own line, in the order the questions are asked.

Examples2

  1. Example 1

    Input
    5 3 3
    1 2 1 3 3
    2 1 3
    1 3 3
    2 1 5
    
    Expected output
    2
    3
    
  2. Example 2

    Input
    6 6 3
    2 3 1 1 1 9
    2 1 3
    2 3 5
    1 3 3
    2 1 5
    1 2 1
    2 1 6
    
    Expected output
    3
    1
    2
    3