#P6447. [COCI 2010/2011 #1] ŽABE
[COCI 2010/2011 #1] ŽABE
Description
The king has servants. He arranges the servants in a circle, and each servant faces the back of the next servant.
Each servant has an ID number, and the sequence always starts from the servant with ID . If a servant moves in front of the servant directly in front of them, this operation is considered cutting in line. For example, if the servants are 1 5 4 3 2 6, and the servant with ID cuts forward by positions, the result becomes 1 2 5 4 3 6.
Note: Everyone faces to the right of the sequence.
When the king announces a number , the servant with ID must cut forward by positions. The king wants to announce some commands to transform the initial sequence into his desired sequence.
Given the initial sequence and the king's desired sequence, you need to output the commands issued by the king in order. The testdata guarantees that the initial sequence and the king's desired sequence are not the same.
Input Format
The input consists of three lines.
The first line contains an integer , as described above.
The second line contains integers , representing the initial sequence.
The third line contains integers , representing the king's desired sequence.
Output Format
Output lines.
Each line contains an integer , as described above.
Note: is the number of operations performed by the king.
6
1 5 4 3 2 6
1 2 5 4 3 6
2
5
1 5 3 2 4
1 5 4 2 3
5
3
5
2
Hint
Explanation of Sample Input/Output 1
If the servants are 1 5 4 3 2 6, and the servant with ID cuts forward by positions, the result becomes 1 2 5 4 3 6.
Constraints
For of the testdata, , , , .
Notes
This problem is translated from COCI2010-2011 CONTEST #1 T6 ŽABE.
Thanks to 我谔谔 for providing the Special Judge.
Thanks to aaron0919 for fixing an error.
Translated by ChatGPT 5
京公网安备 11011102002149号