The problem is
greatly simulated and compared to the tumor... The
most important point is while (n − −) while(n--)while(n−− ) Wheren = − 1 n=-1n=− At 1 o'clock the program will continue to run...because it has been stuck for an hour...
Look at the code specifically, writing step by step will succeed
PS: PS:PS: Too many variables, so let me explain what they mean
ttt is the number of data sets,nnn is the number of sentences in a program
ans ansa n s is the answer to the program,sum sums u m is Xiao Ming's answer
ent ente n t is whether this loop can enter,now nown o w is the loop at the nesting level. The program in this loop is useless
tim timt i m is the current time complexity,rep repr e p refers toFFF ratioEEE a few more
on the code (I think the code is relatively short
#include<bits/stdc++.h>
using namespace std;
string a,b;
int t,n,ans,sum,now,tim,rep,nam[30];
bool ent,vis[30],add[110];
int main(){
scanf("%d",&t);
while(t--){
n=sum=ans=rep=tim=ent=now=0;
memset(vis,0,sizeof(vis));
memset(nam,0,sizeof(nam));
memset(add,0,sizeof(add));
while(b[0]!='O'){
a=b;cin>>b;}
int lena=a.length(),lenb=b.length();
for(int i=0;i<lena;i++)n=(n<<3)+(n<<1)+(a[i]&15);
for(int i=4;i<lenb-1;i++)sum=(sum<<3)+(sum<<1)+(b[i]&15);
while(n>0){
//不是n--!不然程序出不去!!
n--;
cin>>a;
if(a[0]=='F'){
rep++;cin>>a;
if(vis[a[0]-'a'])rep=-1;
else vis[a[0]-'a']=true,nam[rep]=a[0]-'a';
cin>>a>>b;
if(a[0]!='n'&&b[0]=='n'&&!ent)tim++,add[rep]=true;
else if((a[0]=='n'&&b[0]!='n'||(a.length()>b.length())||(a.length()==b.length()&&a>b))&&!ent)
ent=true,now=rep;
}
else if(rep>=0){
//一定要>=0不然会RE
ans=max(ans,tim),vis[nam[rep]]=0;
if(add[rep])add[rep]=false,tim--;
rep--;
if(now>0&&rep<now)now=ent=0;
}
if(rep<0)puts("ERR"),n=-1;
}
if(rep>0)puts("ERR");
else if(rep==0&&ans==sum)puts("Yes");
else if(rep==0&&ans!=sum)puts("No");
}
}