Problem:
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

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>
using namespace std;
#define nn 100008*2
#define lf double
#define mp make_pair
#define ll long long
#define err {puts("No");exit(0);}
int status[nn];int n;
char buf[nn];
int ans[nn];int tot;
void output()
{
	for(int i=0;i<n*2;i++)
	{
		if(ans[i]==0)
		for(int j=i+1;j<n*2;j++)
			if(ans[j]==0)
			{
				ans[i]=ans[j]=++tot;
				i=j;
				break;
			}
	}
	puts("Yes");
	for(int i=0;i<n*2;i++) printf("%d ",ans[i]);
	exit(0);
}
bool operator <(vector<int> a,vector<int> b)
{
	return a.size()>b.size();
}
int main()
{
	cin>>n;int o=0;int N=n*2;
	scanf("%s",buf+1);
	for(int i=1;i<2*n;i++) status[i]=buf[i]-'0',o+=status[i];
	status[0]=1;
	if(o==2*n-1)
	{
		if(n%2==1) err;
		for(int i=0;i<n*2;i+=4)
			ans[i]=ans[i+2]=++tot,ans[i+1]=ans[i+3]=++tot;
		output();
	}
//	if(o%2==0) err;
	vector<vector<int> >gg;
	for(int i=0;i<n*2;i++)
	{
		if(status[i]==0&&status[(i+1)%N]==1)
		{//	cout<<i;
			vector<int> b;b.push_back(i);
			for(int j=(i+1)%N;status[j];j=(j+1)%N) b.push_back(j);
			gg.push_back(b);
		}
	}
	sort(gg.begin(),gg.end());
	int d2=0;
	for(int i=0;i<gg.size();i++) 
		d2+=gg[i].size()-2;
	if(d2%2) err;//cout<<gg[0].size()<<" "<<gg[1].size()<<"\n";
	if(d2%4==2)
	{
		if(gg.size()<=1) err
		if(gg[0].size()>2 and gg[1].size()>2) 
		{
	//		swap(gg[0][0],gg[1][0]);
//	cout<<gg[0][1]<<gg[1][1]<<"\n";
			int e1=gg[0].size()-2,e2=gg[1].size()-2;
			ans[gg[0][e1]]=ans[gg[1][e2]]=++tot;
			gg[0].erase(gg[0].begin()+e1);
			gg[1].erase(gg[1].begin()+e2);
			swap(gg[0][e1],gg[1][e2]);
		}
		else err;
	} 
	vector<int> v2;
	for(int i=0;i<gg.size();i++)
	{
	//	cout<<gg[i][0]<<gg[i][gg[i].size()-1]<<"\n";
		ans[gg[i][0]]=tot+i+1;
		ans[gg[i][gg[i].size()-1]]=tot+(i+1)%(int)(gg.size())+1;
		for(int k=1;k<gg[i].size()-1;k++)
			v2.push_back(gg[i][k]);
	}
	tot+=gg.size();
	for(int i=0;i<v2.size();i+=4)
	{
		ans[v2[i]]=ans[v2[i+2]]=++tot;
		ans[v2[i+1]]=ans[v2[i+3]]=++tot;
	}
	output(); 
}