Under construction

Still being built. Things may change

Token Distance

Time limit2sMemory limit512 MB

Summary
Tokens on squares move over time, and each query asks whether tokens L to R are evenly spaced when sorted by square (ties by token number).
Level

Medium7 of 10

Topics
Segment tree, Sorting, Math
Solved
No attempts yet

Problem

You are playing a board game with squares numbered from 0 to 10910^9 (inclusive) and N tokens numbered from 1 to N. Each token is located in one of the squares, and multiple tokens might be located in the same square. Initially, token i is located in square TiT_i. The distance of two tokens is the difference between the square number where the first token is located and the square number where the second token is located.

For a set of tokens S, we check whether the tokens are well-separated as follows.

  • Let A be the list of tokens in S sorted by increasing square number. If several tokens are in the same square, sort them by increasing token number.
  • If there are fewer than three tokens in A, the tokens are well-separated.
  • Otherwise, the tokens are well-separated if and only if the distance between every two neighbouring tokens in A is the same. Two tokens are neighbouring if their indices in A differ by one.

You perform Q operations of one of these two types:

  1. Move token X to square Y.
  2. Report whether the set of tokens numbered from L to R (inclusive) is well-separated.

Input

The first line contains two integers N and Q (2≤N≤100 0002 \le N \le 100\,000; 1≤Q≤100 0001 \le Q \le 100\,000), the number of tokens and the number of operations. The next line contains N integers TiT_i (0≤Ti≤1090 \le T_i \le 10^9), the initial square of each token. Each of the next Q lines is one of the following.

  • 1 X Y (1≤X≤N1 \le X \le N; 0≤Y≤1090 \le Y \le 10^9): Move token X to square Y.
  • 2 L R (1≤L<R≤N1 \le L < R \le N): Report whether the tokens numbered from L to R are well-separated.

There is at least one operation of the second type.

Output

For each operation of the second type, in input order, print YES or NO on its own line, depending on whether the tokens numbered from L to R are well-separated.

Examples1

  1. Example 1

    Input
    5 7
    1 1 1 10 1
    2 1 3
    2 1 5
    1 5 4
    1 3 7
    2 2 4
    2 2 5
    2 4 5
    
    Expected output
    YES
    NO
    NO
    YES
    YES