P5397 [Ynoi2018] Things Falling from the Sky

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. ![](https://cdn.luogu.com.cn/upload/pic/58812.png) Human? No. Not human. No one would... Have wings. ![](https://cdn.luogu.com.cn/upload/pic/58813.png) 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... ![](https://cdn.luogu.com.cn/upload/pic/58814.png) “Happiness” is not enough to describe how I feel right now. What should I say? Ah, right. I... love you. I love you... Master. ![](https://cdn.luogu.com.cn/upload/pic/58815.png) 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.

Description

Icarus gives you a sequence $a$ of length $n$. You need to process $m$ operations. There are two types of operations: 1. Change the value of every element equal to $x$ in the sequence to $y$. 2. Find a position $i$ such that $a_i=x$ and a position $j$ such that $a_j=y$, so that $|i-j|$ is minimized, and output $|i-j|$.

Input Format

The first line contains two integers $n,m$. The next line contains $n$ integers, representing the sequence $a$. Then follow $m$ lines, each containing three numbers $opt,x,y$. If $opt$ is $1$, it means changing the value at every position with value $x$ to $y$. If $opt$ is $2$, it means finding a position $i$ such that $a_i=x$ and a position $j$ such that $a_j=y$ to minimize $|i-j|$, and output $|i-j|$. If no such positions can be found, output `Ikaros`. This problem is strictly online. For each operation, $x,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 $0$. There are $50$ test cases in total, and it is guaranteed that $n=m$.

Output Format

For each operation of type $2$, output one line with an integer representing the answer. If it is impossible to find $i,j$ that satisfy the statement, output `Ikaros`.

Explanation/Hint

Idea: nzhtl1477, Solution: nzhtl1477, Code: nzhtl1477, Data: nzhtl1477 ( partially uploaded ). Constraints: For $100\%$ of the testdata, all numbers are within $[1,10^5]$, and the value in each operation does not exceed $n$. Translated by ChatGPT 5