#B3639. Circular Lantern Toggling
Circular Lantern Toggling
Circular Lantern Toggling
There are (n) lanterns arranged in a circle, initially all off (denoted by 0). There are also (n) buttons on the console. Pressing the (x)th button toggles the state of lantern (x) and its two adjacent lanterns. Toggling means changing (0) (off) to (1) (on), and (1) (on) to (0) (off). Note that since the lanterns are arranged in a circle, the neighbors of the first and nth lanterns are considered accordingly. For example, pressing button 5 toggles lanterns 4, 5, and 6; pressing button (n) toggles lanterns (n-1), (n) and 1.
Given a series of button presses, determine the final state of all lanterns.
inputFormat
The first line contains two integers (n) and (m), representing the number of lanterns and the number of button presses, respectively. The second line contains (m) integers, each indicating which button is pressed (using 1-indexing), in the order they were pressed.
outputFormat
Output (n) space-separated integers representing the final state of each lantern (0 for off, 1 for on) after processing all button presses.
sample
3 1
1
1 1 1
</p>