#P5397. [Ynoi2018] 天降之物

[Ynoi2018] 天降之物

Background

Have you ever had a dream like this?

Beside me, there is a girl I have never met before.

I like her a lot, and she likes me a lot too.

But—

In the end, it is always

When she is taken away by the sky,

That I wake up from the dream.

Human?

No.

Not human.

No one would...

Have wings.

No, no, no.

There is nowhere.

There is nowhere I can go back to.

I have no place I can go back to!

Nowhere...

A place I can go back to... anywhere... nowhere at all...

I do not want to kill anyone, and I do not want to hurt anyone!

Why... why did you create me...

No need... I do not need this kind of power...

“Happiness” is not enough to describe how I feel right now.

What should I say?

Ah, right.

I... love you.

I love you... Master.

In Greek mythology, Icarus flew too close to the sun; the feathers glued on with wax melted, and he fell into the sea and died.

Problem Description

Icarus gives you a sequence aa of length nn.

You need to process mm operations. There are two types of operations:

  1. Change the value of every element equal to xx in the sequence to yy.
  2. Find a position ii such that ai=xa_i=x and a position jj such that aj=ya_j=y, so that ij|i-j| is minimized, and output ij|i-j|.

Input Format

The first line contains two integers n,mn,m.

The next line contains nn integers, representing the sequence aa.

Then follow mm lines, each containing three numbers opt,x,yopt,x,y.

If optopt is 11, it means changing the value at every position with value xx to yy.

If optopt is 22, it means finding a position ii such that ai=xa_i=x and a position jj such that aj=ya_j=y to minimize ij|i-j|, and output ij|i-j|. If no such positions can be found, output Ikaros.

This problem is strictly online. For each operation, x,yx,y need to be xor-ed with the answer from two queries ago. If the output is Ikaros, or if it is the first query, then the last answer is 00.

There are 5050 test cases in total, and it is guaranteed that n=mn=m.

Output Format

For each operation of type 22, output one line with an integer representing the answer.

If it is impossible to find i,ji,j that satisfy the statement, output Ikaros.

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

Ikaros
1
1

Hint

Idea: nzhtl1477, Solution: nzhtl1477, Code: nzhtl1477, Data: nzhtl1477 ( partially uploaded ).

Constraints: For 100%100\% of the testdata, all numbers are within [1,105][1,10^5], and the value in each operation does not exceed nn.

Translated by ChatGPT 5