#PU1013. USACO 2020 February Contest, Bronze — Problem 3. Swapity Swap
USACO 2020 February Contest, Bronze — Problem 3. Swapity Swap
USACO 2020 February Contest, Bronze — Problem 3. Swapity Swap
题目描述
Farmer John's cows () are standing in a line. The th cow
from the left has label , for each .
Farmer John has come up with a new morning exercise routine for the cows. He
tells them to repeat the following two-step process exactly
() times:
The sequence of cows currently in positions from the left
reverse their order ().
Then, the sequence of cows currently in positions from the
left reverse their order ().
After the cows have repeated this process exactly times, please output the
label of the th cow from the left for each .
输入格式
The first line of input contains and . The second line contains
and , and the third contains and .
输出格式
On the th line of output, print the label of the th cow from the left at
the end of the exercise routine.
数据范围
Test cases 2-3 satisfy .
Test cases 4-13 satisfy no additional constraints.
样例
样例 1
7 2
2 5
3 7
1
2
4
3
5
7
6
Initially, the order of the cows is $[1,2,3,4,5,6,7]$ from left to right. After
the first step of the process, the order is $[1,5,4,3,2,6,7].$ After the second
step of the process, the order is $[1,5,7,6,2,3,4]$. Repeating both steps a
second time yields the output of the sample.
Problem credits: Brian Dean