atcoder#APC001G. Colorful Doors
Colorful Doors
Score : points
Problem Statement
There is a bridge that connects the left and right banks of a river. There are doors placed at different positions on this bridge, painted in some colors. The colors of the doors are represented by integers from through . For each (), there are exactly two doors painted in Color .
Snuke decides to cross the bridge from the left bank to the right bank. He will keep on walking to the right, but the following event will happen while doing so:
- At the moment Snuke touches a door painted in Color (), he teleports to the right side of the other door painted in Color .
It can be shown that he will eventually get to the right bank.
For each (), the section between the -th and -th doors from the left will be referred to as Section .
After crossing the bridge, Snuke recorded whether or not he walked through Section , for each ().
This record is given to you as a string of length .
For each (), if Snuke walked through Section , the -th character in is 1
; otherwise, the -th character is 0
.
Figure: A possible arrangement of doors for Sample Input 3
Determine if there exists an arrangement of doors that is consistent with the record. If it exists, construct one such arrangement.
Constraints
- consists of
0
and1
.
Input
Input is given from Standard Input in the following format:
Output
If there is no arrangement of doors that is consistent with the record, print No
.
If there exists such an arrangement, print Yes
in the first line, then print one such arrangement in the second line, in the following format:
Here, for each (), is the color of the -th door from the left.
2
010
Yes
1 1 2 2
2
001
No
3
10110
Yes
1 3 2 1 2 3
The figure below is identical to the one in the statement.
3
10101
No
6
00111011100
Yes
1 6 1 2 3 4 4 2 3 5 6 5