建树, 然后高度最大值的最小值显然为$\lceil \frac{dep}{2}\rceil$, 将$>\frac{dep}{2}$的全部分出去即可.

#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, P2 = 998244353, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head const int N = 1e6+10;
int n, tot, now, mx;
char s[N], Ans[N];
vector<int> g[N];
int L[N], R[N], dep[N]; void dfs(int x) {
while (s[now]=='(') {
L[tot+1]=now;
++now,g[x].pb(++tot),dfs(tot);
}
R[x]=now++;
}
void dfs(int x, int d) {
mx=max(mx,dep[x]=d);
for (int y:g[x]) dfs(y,d+1);
}
int main() {
scanf("%d%s", &n, s+1);
now=tot=1,dfs(1),dfs(1,0);
memset(Ans,'0',sizeof Ans);
REP(i,1,tot) if (dep[i]>mx/2) Ans[L[i]]=Ans[R[i]]='1';
Ans[n+1]=0;
puts(Ans+1);
}

Bicolored RBS CodeForces - 1167D (括号)的更多相关文章

  1. Codeforces 1167D - Bicolored RBS

    题目链接:http://codeforces.com/problemset/problem/1167/D 题意:题目定义RBS,给你一个字符串,你要对其所有字符染色,使之分解为俩个RBS,使俩个RBS ...

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

    链接:https://codeforces.com/contest/1167/problem/D 题意: A string is called bracket sequence if it does ...

  3. The Monster CodeForces - 917A (括号匹配)

    链接 大意:给定字符串, 只含'(',')','?', 其中'?'可以替换为'('或')', 求有多少个子串可以的括号可以匹配 (不同子串之间独立) 记$s_($为'('个数, $s_)$为')'个数 ...

  4. Neko and Aki's Prank CodeForces - 1152D (括号序列,dp)

    大意: 将所有长度为2*n的合法括号序列建成一颗trie树, 求trie树上选出一个最大不相交的边集, 输出边集大小. 最大边集数一定不超过奇数层结点数. 这个上界可以通过从底层贪心达到, 所以就转化 ...

  5. Bracket Sequences Concatenation Problem CodeForces - 990C(括号匹配水题)

    明确一下  一个字符串有x左括号不匹配  和 另一个字符串有x个右括号不匹配  这俩是一定能够匹配的 脑子有点迷 emm... 所以统计就好了  统计x个左括号的有几个,x个右括号的有几个 然后 乘一 ...

  6. [CF1167D]Bicolored RBS题解

    模拟两个颜色的扩号层数,贪心,如果是左括号,哪边的层数浅就放那边:如果是右括号,哪边的层数深就放那边. 至于层数的维护,两个int就做掉了 放个代码: #include <cstdio> ...

  7. Codeforces 918 括号匹配 SGdp[i][j][k]

    A B C #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) ...

  8. Educational Codeforces Round 65 (Rated for Div. 2)题解

    Educational Codeforces Round 65 (Rated for Div. 2)题解 题目链接 A. Telephone Number 水题,代码如下: Code #include ...

  9. codeforces Educational Codeforces Round 65 (补完)

    C News Distribution 并查集水题 D Bicolored RBS 括号匹配问题,如果给出的括号序列nesting depth为n,那么最终可以分成两个nesting depth为n ...

随机推荐

  1. [CSP-S模拟测试]:B(DP+数学)

    题目传送门(内部题45) 输入格式 第一行$3$个整数$n,m,P$.第二行$m$个整数,表示$m$次询问. 输出格式 一行$m$个整数表示答案. 样例 样例输入1: 2 4 40 1 2 3 样例输 ...

  2. 在jenkins打开roboframework报告:Opening Robot Framework report failed

    来源自: https://blog.51cto.com/icestick8586/1884615 --------------------------------------------------- ...

  3. laravel 文件上传总结

    调用 store 方法会生成唯一的 ID 来作为文件名,如果想获取原件本来的名称可以使用 $file = $request->file('file'); $file->getClientO ...

  4. Simple Cel Shading 钟馗

    Made with Unity Unannouced project Character Art by Chris P

  5. CSS中 Padding和Margin两个属性的详细介绍和举例说明

    代码示例: <!doctype html> <html lang="en"> <head> <meta charset="UTF ...

  6. 八十三:redis之redis的使用场景和安装

    使用场景1.登录会话存储,存储在redis中,与mamcached相比,数据不会丢失2.排行榜.计数器:比如一些秀场类的项目,经常会有一些前多少名的主播排行榜,还有一些文章阅读量.或者点赞数等3.作为 ...

  7. TypeScript 编译目标(target)设置

    TypeScript的编译配置文件tsconfig.json中有许多配置项,本文简单对比编译目标环境的配置项(target)的设置.模块(module)不在本文讨论之内,是另外一个大话题. 实验对于t ...

  8. axios的中文使用文档

    axios 基于promise用于浏览器和node.js的http客户端 原文链接 lewis1990@amoy 特点 支持浏览器和node.js 支持promise 能拦截请求和响应 能转换请求和响 ...

  9. H3C 模拟器 pc与sw直连 开启telnet

    如图所示 1 在pc上添加虚拟网卡,与上一章节的添加方式相同 配置pc的ip地址 10.17.4.3 255.255.252.0 2 sw设置 <sw1>system-view [sw1] ...

  10. java:zookeeper集群配置,dubbo

    1.zookeeper集群配置: 2.dubbo:(配置见视频)