#P15354. [COCI 2025/2026 #4] 体育课 / Tjelesni
[COCI 2025/2026 #4] 体育课 / Tjelesni
Problem Description
You are given a permutation of .
Apply operations to . In the -th operation, you are given , meaning:
- Let .
- For , perform the following steps:
- If is even, let ; otherwise, let .
- Set , and update (that is, remove from ).
Given a positive integer , find the position of the number after all operations.
Input Format
The first line contains three positive integers (, ).
The second line contains positive integers .
The next lines each contain two positive integers ().
Output Format
Output one positive integer in a single line, representing the position of the number after all operations.
7 3 3
4 2 3 7 1 6 5
4 7
3 5
1 4
5
6 4 1
5 3 6 2 1 4
2 4
3 5
2 6
5 6
2
8 2 5
8 7 6 5 4 3 1 2
2 8
1 7
7
Hint
Sample Explanation
Explanation for Sample 1:
- After the first operation, .
- After the second operation, .
- After the third operation, .
The position of the number is .
Subtasks
| Subtask ID | Score | Constraints |
|---|---|---|
| No additional constraints. |
Translated by ChatGPT 5