A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular (shortly, RBS) if it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this sequence. For example, "", "(())" and "()()" are RBS and ")(" and "(()" are not.
We can see that each opening bracket in RBS is paired with some closing bracket, and, using this fact, we can define nesting depth of the RBS as maximum number of bracket pairs, such that the 22-nd pair lies inside the 11-st one, the 33-rd one — inside the 22-nd one and so on. For example, nesting depth of "" is 00, "()()()" is 11and "()((())())" is 33.
Now, you are given RBS ss of even length nn. You should color each bracket of ss into one of two colors: red or blue. Bracket sequence rr, consisting only of red brackets, should be RBS, and bracket sequence, consisting only of blue brackets bb, should be RBS. Any of them can be empty. You are not allowed to reorder characters in ss, rr or bb. No brackets can be left uncolored.
Among all possible variants you should choose one that minimizes maximum of rr's and bb's nesting depth. If there are multiple solutions you can print any of them.
Input
The first line contains an even integer nn (2≤n≤2⋅1052≤n≤2⋅105) — the length of RBS ss.
The second line contains regular bracket sequence ss (|s|=n|s|=n, si∈{si∈{"(", ")"}}).
Output
Print single string tt of length nn consisting of "0"-s and "1"-s. If titi is equal to 0then character sisi belongs to RBS rr, otherwise sisi belongs to bb.
Examples
Input
2 ()
Output
11
Input
4 (())
Output
0101
Input
10 ((()())())
Output
0110001111
Note
In the first example one of optimal solutions is s=s= "()()". rr is empty and b=b= "()()". The answer is max(0,1)=1max(0,1)=1.
In the second example it's optimal to make s=s= "(())(())". r=b=r=b= "()()" and the answer is 11.
In the third example we can make s=s= "((()())())((()())())". r=r= "()()()()" and b=b= "(()())(()())" and the answer is 22.
代码:
//Full of love and hope for life
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <queue>
#include <vector>
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
//https://paste.ubuntu.com/
//https://www.cnblogs.com/zzrturist/ //博客园
//https://blog.csdn.net/qq_44134712 //csdn
using namespace std;
const int maxn=5e3+10;
typedef long long ll;
const int mod=1e9+7;
int main(){
int a;
cin >> a;
char s[200010];
cin >> s;
int l=0;
int r=0;
// int len=strlen(s);
for(int i=0;i<a;i++){
if(s[i]=='('){
if(l<=r){
l++;
cout << "1";
}
else{
r++;
cout << "0";
}
}
else{
if(l>0){
l--;
cout << "1";
}
else{
r--;
cout << "0";
}
}
}
return 0;
}