0_0_27955326_22361.cpp: In function 'int main()':
0_0_27955326_22361.cpp:39:420: error: expected '}' at end of input
if(s[i]=='(') {st.push(i);p=i;break;} }p++; while(p<=s.size()-1) { if(s[p]=='(')st.push(p); else { int k=st.empty()?0:st.top(); if(st.empty()) {p++;continue;} vis[p]=k; vis[k]=p; if(!st.empty())st.pop(); up[p]=up[vis[p]]=st.empty()?-1:st.top(); } p++; }}void Read(int& x){ x=0; char c;int flag=0; while(c=getchar()) { if(c>='0'&&c<='9')x*=10,x+=c-'0',flag=1; else if(flag)break; }}int main(){ //freopen("rand.out", "r", stdin); //freopen("w.out", "w", stdout); Read(t); while(t--) { char ss[MAXN]={}; scanf("%s",ss); string sss(ss); s=sss; len=s.size(); init(); long long loe=0; make_vis(); for(int i=0;i<s.size();i++) if(s[i]==')'&&vis[i]!=-1) b[i]=b[vis[i]-1]+1; for(int j=s.size()-1;j>=0;j--) if(s[j]=='('&&vis[j]!=-1) a[j]=a[vis[j]+1]+1; for(int i=0;i<s.size();i++) { if(up[i]!=-1&&!ans[i]&&vis[i]!=-1) ans[i]=ans[vis[i]]=ans[up[i]]+(long long)a[i]*b[vis[i]]; else if(up[i]==-1&&!ans[i]&&vis[i]!=-1) ans[i]=ans[vis[i]]=(long long)a[i]*b[vis[i]]; } for(int i=0;i<s.size();i++) { loe=(loe+ans[i]*(i+1)%zqf); } printf("%I64d\n",loe); }}
^
|