| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 3 초 | 2048 MB | 4 | 3 | 2 | 100.000% |
Randias is playing a card game. In this game, each card has a number written on it. For cards with numbers $a_{1}, a_{2}, \ldots, a_{m},ドル Randias will play the game in the following way.
Initially, all cards are in his hand. Randias will maintain a card sequence (initially empty). In the $i$-th operation, Randias will put the $i$-th card (this card has number $a_{i}$ written on it) at the end of the card sequence. Then:
For example, let $a = [2, 1, 3, 1, 2, 3],ドル and the card sequence $s = []$ initially.
After the 1ドル$-st operation, $s = [2]$.
After the 2ドル$-nd operation, $s = [2, 1]$.
After the 3ドル$-rd operation, $s = [2, 1, 3]$.
After the 4ドル$-th operation, $s = [2]$ (cards 1,ドル 3, 1$ are taken away).
After the 5ドル$-th operation, $s = []$ (cards 2,ドル 2$ are taken away).
After the 6ドル$-th operation, $s = [3]$.
Now, Randias is given $n$ cards $a_{1}, a_{2}, \ldots, a_{n}$. He has $q$ queries. The $i$-th query is a pair of integers $\ell_{i}, r_{i}$. With this query, Randias wants to know how many cards will be left in the card sequence if the initial list of cards is $a_{\ell_{i}}, a_{\ell_{i} + 1}, \ldots, a_{r_{i}}$.
For some reason, Randias hopes you can answer the questions online. That is, you need to decode the next question with the answer for the previous question.
The first line contains two integers $n$ and $q$ (1ドル \le n, q \le 3 \cdot 10^5$) denoting the number of cards and the number of queries.
The following line contains $n$ integers $a_{1}, a_{2}, \ldots, a_{n}$ (1ドル \le a_{i} \le n$).
Each of the following $q$ lines contains two integers $\ell'_{i}$ and $r'_{i}$ (0ドル \le \ell'_{i} ,r'_{i} \le 2n$). Let the answer for the last query is $\mathit{lastans}$. Then $\ell_{i} = \ell'_{i} \oplus \mathit{lastans}$ and $r_{i} = r'_{i} \oplus \mathit{lastans}$ are the next query. In these formulas, $\oplus$ is the bitwise exclusive OR operation. It is guaranteed that, after decoding, 1ドル \le \ell_{i} \le r_{i} \le n$. If you haven't answered any queries before, $\mathit{lastans} = 0$.
For each query, output a line with one integer: the answer to that query.
5 5 3 3 1 1 1 5 5 3 4 3 3 0 5 3 5
1 2 1 0 1
7 7 2 4 1 2 3 1 2 1 6 0 4 3 3 0 4 0 3 0 6 2 7
2 1 1 1 2 3 0
For the first example, the segments in the queries are $[5, 5],ドル $[2, 5],ドル $[1, 1],ドル $[1, 4],ドル and $[3, 5]$.