#abc279e. E - Cheating Amidakuji
E - Cheating Amidakuji
Score : points
问题描述
你得到一个长度为 的整数序列,其中的整数范围在 到 (包含两端)之间:。对于 ,解答以下问题:
- 存在一个序列 。初始时,我们有 对于所有 。按照以下顺序执行操作(换句话说,针对从 到 (不包括 )的升序整数 ):
- 将 和 的值进行交换。
- 所有操作完成后,令 为满足 的 值。求出 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a sequence of length consisting of integers between and , inclusive: . Answer the following question for .
- There is a sequence . Initially, we have for each . Let us perform the following operation for in this order (in other words, for integers between and except in ascending order).
- Swap the values of and .
- After all the operations, let be the value of such that . Find .
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the value as an integer.
Sample Input 1
5 4
1 2 3 2
Sample Output 1
1
3
2
4
For , the operations change as follows.
- Initially, .
- Perform the operation for . That is, swap the values of and , making .
- Perform the operation for . That is, swap the values of and , making .
- Perform the operation for . That is, swap the values of and , making .
After all the operations, we have , so .
Similarly, we have the following.
- For : performing the operation for in this order makes , so .
- For : performing the operation for in this order makes , so .
- For : performing the operation for in this order makes , so .
Sample Input 2
3 3
2 2 2
Sample Output 2
1
1
1
Sample Input 3
10 10
1 1 1 9 4 4 2 1 3 3
Sample Output 3
2
2
2
3
3
3
1
3
4
4
update @ 2024/3/10 11:44:48