sscanf读入数字,getline(cin,string)读一整行,其余暴力模拟即可。
1 #include2 #include 3 #include 4 #include 5 #include 6 #define rep(i,l,r) for (int i=(l); i<=(r); i++) 7 typedef long long ll; 8 using namespace std; 9 10 const int N=110;11 int T,n,w[N];12 char p[N],s[N];13 string str;14 15 int main(){16 freopen("comp.in","r",stdin);17 freopen("comp.out","w",stdout);18 for (scanf("%d",&T); T--; ){19 scanf("%d%s",&n,p); int d,ans=0,top=0; bool flag=0;20 if (p[2]=='1') d=0; else sscanf(p+4,"%d",&d);21 rep(i,1,n){22 if (flag) { getline(cin,str); continue; }23 scanf("%s",p);24 if (p[0]=='F'){25 scanf("%s",p); s[++top]=p[0]; int x=0,a,b;26 scanf("%s",p); if (p[0]=='n') a=101; else sscanf(p,"%d",&a);27 scanf("%s",p); if (p[0]=='n') b=101; else sscanf(p,"%d",&b);28 if (a>b) w[top]=0;29 else if (a 0; puts(flag?"ERR":ans==d?"Yes":"No");40 }41 return 0;42 }