#P6148. [USACO20FEB] Swapity Swapity Swap S
[USACO20FEB] Swapity Swapity Swap S
Description
Farmer John’s cows () are standing in a line. For each , the ID of the -th cow from left to right is .
Farmer John has come up with a new morning exercise plan for the cows. He gives the cows pairs of integers , where . He asks them to repeat the following process, which consists of steps, a total of times ():
For each from to :
- Reverse the order of the cows currently in positions from left to right.
- After the cows repeat this process times, output, for each , the ID of the -th cow from left to right.
Input Format
The first line contains , , and . For each , line contains and , both integers in the range , with .
Output Format
On line , output the ID of the -th element (from left to right) in the cow sequence after the instruction sequence has been executed times.
7 2 2
2 5
3 7
1
2
4
3
5
7
6
Hint
Sample Explanation:
Initially, the cows are ordered from left to right as []. After the first step of this process, the order becomes []. After the second step of this process, the order becomes []. Repeating these two steps one more time each gives the sample output.
Subtasks:
- Test case satisfies .
- Test cases - satisfy .
- Test cases - have no additional constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号