不是特别懂题目意思,不追求AC,至少拿到暴力的分
#include<bits/stdc++.h>
using namespace std;
int n,k,ans;
string s;
vector<string>a;
bool pp(string c){
int a=0,b=0;
for(int i=0;i<c.size();i++){
b+=c[i]==')';
if(b>a)return 0;
a+=c[i]=='(';
}
return a==b&&c[c.size()-1]!='*'&&c[0]!='*';
}
bool xz(string c){
for(int i=0;i<c.size()-4;i++){
if(c[i]=='('&&c[i+1]=='*'&&c[i+2]=='*'&&c[i+3]=='(')return 0;
if(c[i]==')'&&c[i+1]=='*'&&c[i+2]=='*'&&c[i+3]==')')return 0;
}
//for(int i=0;i<c.size()-2;i++){
//if(c[i]=='')
//}
return 1;
}
void ff(){
cin>>n>>k>>s;
clock_t cl=clock();
for(int i=0;i<100000;i++){
string c=s;
while(count(c.begin(),c.end(),'?')>0){
int b=-1;
while(b<0||(c[b]!='?'&&c[b]!='('&&c[b]!=')'))
b=rand()%(s.size());
int d=rand()%3;
if(d==0)
c[b]='(';
else if(d==1)
c[b]=')';
else
c[b]='*';
}
//cout<<c<<" "<<pp(c)<<"-";
if(pp(c)&&count(c.begin(),c.end(),'*')==k&&xz(c))
if(!count(a.begin(),a.end(),c))
ans++,
a.push_back(c);//cout<<c<<"\n";
if(clock()-cl>CLOCKS_PER_SEC*1.5)return;
}
}
int main(){
ff();
cout<<ans;
return 0;
}