#P2250. 二面体群
二面体群
Description
Consider points on a unit circle, labeled . Initially, the angle of relative to the X-axis is degrees, measured counterclockwise from the X-axis. We will perform two types of operations on this set of points:
- Rotate clockwise by degrees.
- Reflect with respect to the X-axis.
For a given operation sequence, if the results are the same, we are only interested in the shortest operation sequence. “Results are the same” means that, for different operation sequences, the final position of each individual point is identical.
Operation sequences are given as strings consisting only of the letters r and m. r denotes a clockwise rotation, and m denotes a reflection about the X-axis. If a letter appears consecutively, it must be abbreviated as . For convenience, a single letter is also written in this form. For example, rrmrrrrrrrrrrrr can be written as r2 m1 r12, one operation sequence per line.
Input Format
The input consists of two lines.
The first line contains an integer , the number of points on the circle.
The second line contains the operation sequence abbreviated as described above. All numbers are positive integers and less than . There are no blank lines in the input file, and the number of characters on each line is less than .
Output Format
Output the shortest operation sequence. If no operation is needed, output nothing.
54
r218 m3 r1
r1 m1
Hint
of the testdata satisfies .
Translated by ChatGPT 5
京公网安备 11011102002149号