Choreography
시간 제한0.5초메모리 제한1024 MB
시작 배열과 이동 동작이 순차적으로 추가될 때, 특정 시점까지 추가된 모든 이동을 수행한 뒤 주어진 무용수가 최종적으로 서 있는 위치를 답한다.
문제
The Hungarian National Dance Ensemble is practicing a new choreography. There are dancers in the ensemble, numbered from to , where is an even number.
At the practice sessions, the choreographer first lines up the dancers. The positions in the line are numbered from to , and position is occupied by dancer at the start.
After the dancers line up, the choreographer asks them to perform a sequence of moves. Each move must be completed before they begin performing the next one. The dancers are practicing types of moves:
-
Every dancer moves positions to the right cyclically, where . That is,
- for each from to , inclusive, the dancer currently standing at position moves to position , and
- for each from to , inclusive, the dancer currently standing at position moves to position .
-
Every dancer moves positions to the left cyclically, where . That is,
- for each from to , inclusive, the dancer currently standing at position moves to position , and
- for each from to , inclusive, the dancer currently standing at position moves to position .
-
For each from to , inclusive, dancers at positions and swap places.
-
Suppose that position () is occupied by dancer before performing this move. For each from to , inclusive, dancer moves to position .
Note that the positions of the dancers are distinct at the end of each move.
Before the next session, the choreographer plans a sequence of moves for the ensemble to practice. He adds the moves to the sequence one by one. Sometimes, before adding the next move, he wonders which positions certain dancers will occupy right after performing every move that has been added to the sequence.
Your task is to simulate the dance moves planned by the choreographer and answer his questions about the positions of the dancers.
제한
- (for each such that )
- (for each and such that )
예제
이 문제는 공개된 예제가 없습니다.