#P2391. Snowflake Coloring
Snowflake Coloring
Snowflake Coloring
There are \( n \) snowflakes arranged in a row. Pty performs \( m \) coloring operations. In the \( i \)-th operation, two snowflakes at positions \( a = (((i\times p)+q) \bmod n)+1 \) and \( b = (((i\times q)+p) \bmod n)+1 \) are chosen. All snowflakes between positions \( \min(a, b) \) and \( \max(a, b) \) (inclusive) are painted with color \( i \). If a snowflake is not colored by any operation, its color remains \( 0 \). Determine the final color of each snowflake.
inputFormat
Four space-separated integers: n m p q, where n is the number of snowflakes, m is the number of operations, and p, q are given positive integers.
outputFormat
Print n integers representing the color of each snowflake after all operations, separated by spaces.
sample
5 2 1 2
2 2 2 2 2