luogu#P9951. [USACO20FEB] Swapity Swap B
[USACO20FEB] Swapity Swap B
Problem 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. He has them repeat the following two-step process times ():
- Reverse the order of the cows currently in positions from left to right ().
- Then, reverse the order of the cows currently in positions from left to right ().
After the cows repeat this process times, output the ID of the -th cow from left to right for each .
Input Format
The first line contains and . The second line contains and , and the third line contains and .
Output Format
On the -th line, output the ID of the -th cow from left to right after the exercise ends.
7 2
2 5
3 7
1
2
4
3
5
7
6
Hint
Sample Explanation 1
Initially, the cows’ order from left to right is . 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 produces the sample output.
Test Point Properties
- Test points satisfy .
- Test points have no additional constraints.
Translated by ChatGPT 5