Educational Codeforces Round 65 (Rated for Div. 2)(D - Bicolored RBS )

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;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
资源包主要包含以下内容: ASP项目源码:每个资源包中都包含完整的ASP项目源码,这些源码采用了经典的ASP技术开发,结构清晰、注释详细,帮助用户轻松理解整个项目的逻辑和实现方式。通过这些源码,用户可以学习到ASP的基本语法、服务器端脚本编写方法、数据库操作、用户权限管理等关键技术。 数据库设计文件:为了方便用户更好地理解系统的后台逻辑,每个项目中都附带了完整的数据库设计文件。这些文件通常包括数据库结构图、数据表设计文档,以及示例数据SQL脚本。用户可以通过这些文件快速搭建项目所需的数据库环境,并了解各个数据表之间的关系和作用。 详细的开发文档:每个资源包都附有详细的开发文档,文档内容包括项目背景介绍、功能模块说明、系统流程图、用户界面设计以及关键代码解析等。这些文档为用户提供了深入的学习材料,使得即便是从零开始的开发者也能逐步掌握项目开发的全过程。 项目演示与使用指南:为帮助用户更好地理解和使用这些ASP项目,每个资源包中都包含项目的演示文件和使用指南。演示文件通常以视频或图文形式展示项目的主要功能和操作流程,使用指南则详细说明了如何配置开发环境、部署项目以及常见问题的解决方法。 毕业设计参考:对于正在准备毕业设计的学生来说,这些资源包是绝佳的参考材料。每个项目不仅功能完善、结构清晰,还符合常见的毕业设计要求和标准。通过这些项目,学生可以学习到如何从零开始构建一个完整的Web系统,并积累丰富的项目经验。
&quot;educational codeforces round 103 (rated for div. 2)&quot;是一个Codeforces平台上的教育性比赛,专为2级选手设计评级。以下是有关该比赛的回答。 &quot;educational codeforces round 103 (rated for div. 2)&quot;是一场Codeforces平台上的教育性比赛。Codeforces是一个为程序员提供竞赛和评级的在线平台。这场比赛是专为2级选手设计的,这意味着它适合那些在算法和数据结构方面已经积累了一定经验的选手参与。 与其他Codeforces比赛一样,这场比赛将由多个问题组成,选手需要根据给定的问题描述和测试用例,编写程序来解决这些问题。比赛的时限通常有两到三个小时,选手需要在规定的时间内提交他们的解答。他们的程序将在Codeforces的在线评测系统上运行,并根据程序的正确性和效率进行评分。 该比赛被称为&quot;educational&quot;,意味着比赛的目的是教育性的,而不是针对专业的竞争性。这种教育性比赛为选手提供了一个学习和提高他们编程技能的机会。即使选手没有在比赛中获得很高的排名,他们也可以从其他选手的解决方案中学习,并通过参与讨论获得更多的知识。 参加&quot;educational codeforces round 103 (rated for div. 2)&quot;对于2级选手来说是很有意义的。他们可以通过解决难度适中的问题来测试和巩固他们的算法和编程技巧。另外,这种比赛对于提高解决问题能力,锻炼思维和提高团队合作能力也是非常有帮助的。 总的来说,&quot;educational codeforces round 103 (rated for div. 2)&quot;是一场为2级选手设计的教育性比赛,旨在提高他们的编程技能和算法能力。参与这样的比赛可以为选手提供学习和进步的机会,同时也促进了编程社区的交流与合作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ZZ --瑞 hopeACMer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值