G - Colorful Doors Editorial /

Time Limit: 2 sec / Memory Limit: 256 MB

配点 : 2000

問題文

左岸と右岸を繋ぐ橋があります。 橋の上の相異なる 2 N 箇所には、それぞれある色のドアが置かれています。 各ドアの色は 1 から N までの整数で表されます。 各 k (1 \leq k \leq N) について、色 k のドアはちょうど 2 個存在します。

すぬけ君は、左岸から右岸へ橋を渡ることにしました。 すぬけ君は常に右へ向かって歩き続けますが、その間に次の現象が起こります。

  • すぬけ君が色 k (1 \leq k \leq N) のドアに触れた瞬間、すぬけ君は色 k の他方のドアのすぐ右へワープする。

すぬけ君はいずれ右岸に辿り着くことが示せます。

i (1 \leq i \leq 2 N - 1) について、左から i 番目および i + 1 番目のドアに挟まれた区間を、区間 i と呼ぶことにします。 橋を渡り終えたすぬけ君は、各 i (1 \leq i \leq 2 N - 1) について、区間 i を歩いたか否かを記録しました。 この記録が、長さ 2 N - 1 の文字列 s として与えられます。 各 i (1 \leq i \leq 2 N - 1) について、すぬけ君が区間 i を歩いたならば、si 文字目は 1 であり、そうでないならば、si 文字目は 0 です。

図: 入力例 3 に対応するドアの配置の例

記録に矛盾しないようなドアの配置が存在するか判定し、存在するならばひとつ構成してください。

制約

  • 1 \leq N \leq 10^5
  • |s| = 2 N - 1
  • s01 のみからなる。

入力

入力は以下の形式で標準入力から与えられる。

N
s

出力

記録に矛盾しないようなドアの配置が存在しないならば、No を出力せよ。 存在するならば、1 行目に Yes を出力し、2 行目にドアの配置をひとつ次のフォーマットで出力せよ。 ただし、各 i (1 \leq i \leq 2 N) について、c_i は左から i 番目のドアの色である。

c_1 c_2 ... c_{2 N}

入力例 1

2
010

出力例 1

Yes
1 1 2 2

入力例 2

2
001

出力例 2

No

入力例 3

3
10110

出力例 3

Yes
1 3 2 1 2 3

以下の図は問題文中のものと同様です。


入力例 4

3
10101

出力例 4

No

入力例 5

6
00111011100

出力例 5

Yes
1 6 1 2 3 4 4 2 3 5 6 5

Score : 2000 points

Problem Statement

There is a bridge that connects the left and right banks of a river. There are 2 N doors placed at different positions on this bridge, painted in some colors. The colors of the doors are represented by integers from 1 through N. For each k (1 \leq k \leq N), there are exactly two doors painted in Color k.

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 k (1 \leq k \leq N), he teleports to the right side of the other door painted in Color k.

It can be shown that he will eventually get to the right bank.

For each i (1 \leq i \leq 2 N - 1), the section between the i-th and (i + 1)-th doors from the left will be referred to as Section i. After crossing the bridge, Snuke recorded whether or not he walked through Section i, for each i (1 \leq i \leq 2 N - 1). This record is given to you as a string s of length 2 N - 1. For each i (1 \leq i \leq 2 N - 1), if Snuke walked through Section i, the i-th character in s is 1; otherwise, the i-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

  • 1 \leq N \leq 10^5
  • |s| = 2 N - 1
  • s consists of 0 and 1.

Input

Input is given from Standard Input in the following format:

N
s

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:

c_1 c_2 ... c_{2 N}

Here, for each i (1 \leq i \leq 2 N), c_i is the color of the i-th door from the left.


Sample Input 1

2
010

Sample Output 1

Yes
1 1 2 2

Sample Input 2

2
001

Sample Output 2

No

Sample Input 3

3
10110

Sample Output 3

Yes
1 3 2 1 2 3

The figure below is identical to the one in the statement.


Sample Input 4

3
10101

Sample Output 4

No

Sample Input 5

6
00111011100

Sample Output 5

Yes
1 6 1 2 3 4 4 2 3 5 6 5