#include<iostream>
#include<cstring>
using namespace std;
int main(){
int t;
cin>>t;
for(int i=0;i<t;i++){
int n;
cin>>n;
char str[n+1];
cin>>str;
char stack[n+1];
int j = 0,k = -1;
while(str[j]!='\0'){
if(str[j]=='('){
k++;
stack[k] = '(';
}else{
if(stack[k]=='('){
stack[k] = ' ';
k--;
}else{
k++;
stack[k] = ')';
}
}
j++;
}
cout<<(k+1)/2<<endl;
}
}
C. Move Brackets
最新推荐文章于 2022-09-04 16:23:10 发布