题目大意:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
char s[200000+10];
char a[200000+10],b[200000+10];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int T;
cin >> T;
while(T--){
cin >> n >> (s+1);
ll cnt=0;
for(ll i=1;i<=n;i++){
if(s[i]=='1'){
cnt++;
}
}
if(s[1]=='0'||s[n]=='0'||cnt%2){
cout << "NO" << endl;
}else{
ll cnt0=0,cnt1=0;
for(ll i=1;i<=n;i++){
if(s[i]=='1'){
cnt1++;
a[i]=b[i]=(cnt1<=cnt/2?'(':')');
}else if(s[i]=='0'){
cnt0++;
a[i]=(cnt0%2?'(':')');
b[i]=(cnt0%2?')':'(');
}
}
cout << "YES" << endl;
for(ll i=1;i<=n;i++)cout << a[i];
cout << endl;
for(ll i=1;i<=n;i++)cout << b[i];
cout << endl;
}
}
return 0;
}
标签:200000,10,int,ll,cin,char,CF1503A,Balance,Bits
From: https://www.cnblogs.com/ningziang/p/17671447.html