atcoder#AGC044C. [AGC044C] Strange Dance
[AGC044C] Strange Dance
Score : points
Problem Statement
There are people dancing in circle. We denote with the positions in the circle, starting from an arbitrary position and going around clockwise. Initially each position in the circle is occupied by one person.
The people are going to dance on two kinds of songs: salsa and rumba.
- When a salsa is played, the person in position goes to position , where is the number obtained replacing all digits with and all digits with when reading in base (e.g., the person in position goes to position ).
- When a rumba is played, the person in position moves to position (with the identification ).
You are given a string such that S
if the -th song is a salsa and R
if it is a rumba.
After all the songs have been played, the person that initially was in position is in position .
Compute the array .
Constraints
- contains only the characters
S
andR
.
Input
Input is given from Standard Input in the following format:
Output
You should print on Standard Output:
1
SRS
2 0 1
Before any song is played, the positions are: , , .
When we say "person ", we mean "the person that was initially in position ".
- After the first salsa, the positions are: , , .
- After the rumba, the positions are: , , (so, person is in position , person is in position and person is in position ).
- After the second salsa, the positions are , , (so, person is in position , person is in position and person is in position ).
2
RRSRSSSSR
3 8 1 0 5 7 6 2 4
3
SRSRRSRRRSRRRR
23 9 22 8 3 7 20 24 19 5 18 4 17 12 16 2 6 1 14 0 13 26 21 25 11 15 10