Woburn Challenge 2015-16 Round 2 - Senior Division
"Always two there are, no more, no less. A master and a n00b."
"But which was destroyed, the master or the n00b?"
The exciting climax of the highly-anticipated 1999 Star Wars prequel features four distinct action sequences occurring simultaneously:
- Jar Jar Binks leads the Gungan army in a diversionary battle against the Trade Federation's droid army on the plains of Naboo.
- Queen Amidala and her security force storm the palace in Theed in an attempt to locate and arrest Viceroy Nute Gunray.
- Obi-Wan Kenobi and Qui-Gon Jinn have a lightsaber duel against the Sith lord Darth Maul.
- Anakin Skywalker pilots a Naboo starfighter into orbit amidst a massive dogfight, attempting to take out the Trade Federation's droid control ship.
During this time, the film needs to cut back and forth between these settings. In particular, there are scenes to fill, with each scene observing one of the settings. Additionally, no two consecutive scenes may be assigned to the same setting.
Some of the scenes have already been assigned to settings, while others haven't been. The status of the -th scene is indicated by the value of . If , then the scene is currently unassigned, and if , then the scene must observe setting .
Your job is to assign each of the unassigned scenes to one of the settings, such that no two consecutive scenes are assigned to the same one. It's guaranteed that this will be possible. However, it may be possible in multiple ways, in which case you must choose the one that minimizes the "numeric representation" of the scenes. The numeric representation consists of concatenating the values of the scenes' assigned settings, in order from to , and treating the result as an integer (with each digit in the range ).
Input Specification
The first line of input consists of a single integer .
The second line consists of space-separated integers to .
Output Specification
Output on a single line the numeric representation of your finalized scenes.
Sample Input
8
0 4 1 0 0 1 3 0
Sample Output
14123131
Comments