#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef vector<int> VI;
int n,m;
int main(){
cin>>n;
cin>>s;
int st =0;
string ans;
for(auto x :s){
if(x == ')' && st !=0){
while(ans.back()!='(') ans.pop_back();
ans.pop_back();
st--;
}else{
ans.push_back(x);
if(x == '(') st++;
}
}
cout<<ans;
}
思路是对的,但对于字符串的用法不熟悉,搞得自己写了一个 脑瘫的枚举然后就t了
string感觉属于是一个vector<char>