题目传送门:
大模拟不解释
#include#include #include #include #include #include using namespace std;int T;int main() { cin>>T; for(; T--;) { int n,want=0; scanf("%d",&n); scanf(" O("); char qwe=getchar(); if(qwe=='n') { scanf("^"); for(;;) { char t=getchar(); if(t==')') break; want=want*10+int(t-'0'); } } else if(qwe=='1') { want=0; scanf(")"); } getchar(); int hard=0; int flag=-1; int ans=0; bool jl[30]; for(int i=0; i<30; i++) jl[i]=0; int stack[200],ts[200],top=0; bool boom=0; char pig[20];//bakacirno for(int i=1; i<=n; i++) { if(boom==1) { //ERRcontinue cin.getline(pig,19); continue; } char type=getchar(); if(type=='F') { //F char qqq; scanf(" %c ",&qqq); int name=qqq-'a';//getname if(jl[name]==1) { //ERR boom=1; cin.getline(pig,19); continue; } jl[name]=1;//jl stack[top]=name;//instack top++; ts[top]=0;//init int x=0,y=0; char tcl=getchar();//getx if(tcl=='n') { x=-1; getchar(); } else { x=int(tcl-'0'); for(;;) { int t=getchar(); if(t==' ') break; x=x*10+int(t-'0'); } } tcl=getchar();//gety if(tcl=='n') { y=-1; getchar(); } else { y=int(tcl-'0'); for(;;) { int t=getchar(); if(t=='\n') break; y=y*10+int(t-'0'); } } if(x!=-1&&y!=-1){ if(x>y){ if(flag==-1) flag=top;//sameA } }else if(x==-1&&y==-1){ }else if(x!=-1&&y==-1){ if(flag==-1){ hard++; ts[top]=1; ans=max(ans,hard); } }else if(x==-1&&y!=-1){ if(flag==-1){flag=top;}//sameA } } else if(type=='E') { top--; if(top<0){ //ERR boom=1; getchar(); continue; } if(ts[top+1]==1&&flag==-1) hard--; jl[stack[top]]=0; if(top==flag) flag=-1; getchar(); } } if(boom==1||top!=0) printf("ERR"); else { if(want==ans) printf("Yes"); else printf("No"); } printf("\n"); } return 0;}