Sakura Reflection
Time limit1sMemory limit1024 MB
Given N axes at angles A_i, decide whether reflecting across each axis exactly once can return the image to its start, and output one valid order if so.
- Level
Medium6 of 10
- Topics
- Geometry, Dynamic programming
- Solved
- No attempts yet
Problem

Album art of Ryu☆ - Sakura Reflection
Sakura Reflection is a song by Ryu☆, included on REFLEC BEAT. As the title says, now let us reflect the album art. You are given axes that pass through the center of the album art. The -th axis makes an angle of counterclockwise with the horizontal line. You can reflect the album art across each axis. Keep in mind that rotating the album art by an angle that is not a multiple of , or reflecting it once across a single axis, does not return the album art to its original state.
Ryu☆ wants to reflect the album art times, using each of the axes exactly once. In the harsh world of reflections, the result can differ depending on the order of reflections. (a) reflects across the axis and then the axis. (b) reflects across the axis and then the axis.

Two reflection orders. The result can differ depending on the order.
Can the album art be returned to its original state by reflecting across each of the axes exactly once? If so, find one such order.
Input
The first line contains the number of axes .
The next line contains , the angles the axes make with the horizontal line, separated by spaces.
All numbers in the input are integers.
Output
On the first line, print YES if the album art can be returned to its original state using the given axes, and NO otherwise.
If it is possible, print on the next line integers , separated by spaces, giving the axis numbers in the order they are used for reflection. Each must be a distinct integer from to . After reflecting across the -th, -th, ..., -th axes in that order, the album art must be in its original state.