Fast Search

View as PDF

Submit solution

Points: 15 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

Chunky Munky has an array of N numbers a1,a2,,aN, along with Q queries.

Each query is one of the following 2 types:

  • 1 p x: Set ap=x.
  • 2 l r k: Chunky Munky picks up al, then al+1,al+2, all the way until ar, and would like to know the index of the first element he picks up with a value strictly less than k. It's guaranteed that the value of k will always be such that he will pick up a value strictly less than k during the process.

Help Chunky Munky answer his queries!

Note that this problem will be online enforced, meaning that input will be given in an encrypted format. To encrypt the data, the values p,x,l,r,k in queries will be given as plastAns,xlastAns,llastAns,rlastAns,klastAns, where denotes the bitwise XOR operation. Note that lastAns at any time is defined as the answer to the latest type 2 query. If no type 2 queries have occurred so far, lastAns=0.

Constraints

For all subtasks:

1N,Q106

1ai,x,k109

1pN

1lrN

For 3 of 20 points, 1N,Q2000.

For 10 of 20 points, 1N,Q100000.

For all 20 points, no additional constraints apply.

Input Specification

The first line contains the integers N and Q.

The second line contains the array a1,a2,,aN.

The next Q lines each contain a query of one of the above types.

Output Specification

For each query of type 2, output its answer on a separate line.

Sample Input

Copy
10 5
3 1 4 1 5 9 2 6 5 3
2 6 10 6
2 2 14 1
2 6 2 6
1 0 14
2 7 3 7

Sample Input (Unencrypted)

Copy
10 5
3 1 4 1 5 9 2 6 5 3
2 6 10 6
2 5 9 6
2 3 7 3
1 4 10
2 3 7 3

Sample Output

Copy
7
5
4
7

Comments

There are no comments at the moment.