Dance on the Circle
Time limit2sMemory limit512 MB
Simulate N men dancing around a circle of N women through rotation moves and adjacent swaps, then report which man faces each woman at the end.
- Level
Easy3 of 10
- Topics
- Simulation, Implementation, Math
- Solved
- No attempts yet
Problem
men and women dance in a circle. is even. The women stand still on the inside of the circle and the men move around the outside. The men are numbered 1 to clockwise and the women are numbered 1 to clockwise. At the start, the man and the woman with the same number face each other. The dance is a sequence of moves, and there are two kinds of move.
- An integer is given, and every man moves places clockwise. If is negative, every man moves places counterclockwise.
- The man standing in front of an odd numbered woman trades places with the man standing in front of the next even numbered woman. That is, for every with , the man in front of woman and the man in front of woman swap places.
After all moves are performed, report which man faces which woman.
Input
The first line contains and . (, , is even)
Each of the next lines describes one move, in the order the moves are performed. The first number on a line is the kind of the move. If that number is 1, one integer follows on the same line. If it is 2, nothing follows. So every line has the form "1 x" or "2". ()
Output
Print integers on one line, separated by single spaces. The -th integer is the number of the man who faces woman after the dance ends.