似乎不应该输出ERR直接break?
by hanmo0321 @ 2019-02-27 18:55:29
改完了,还是RE,o(TヘTo)
```cpp
#include<bits/stdc++.h>
using namespace std;
char st[15],s1[15],s2[15],s3[15],s4[15];
int t,h,top,flor,max_fl,Max,sta[205],ans,sta1[205],sta2[205];
bool ERR,f[97+26+5+200],rf;
int length(char s[15]){
int ans;
for(int i=0;s[i];i++) ans++;
return ans;
}
int main(){
scanf("%d",&t);
while(t--){
scanf("%d%s",&h,st);
ERR=0;top=0;flor=0;max_fl=0;ans=0;Max=0;
for(int j=1;j<=h;j++){
scanf("%s",s1);
if(s1[0]=='F'){
scanf("%s%s%s",s2,s3,s4);
if(f[s2[0]]) ERR=1;
f[s2[0]]=1;
int x=0,y=0,c=0;flor++;
max_fl=max(max_fl,flor);
if(s3[0]>='0' && s3[0]<='9'){
int len=length(s3);
for(int i=0;i<len;i++) x=x*10+s3[i]-48;
}
if(s4[0]>='0' && s4[0]<='9'){
int len=length(s4);
for(int i=0;i<len;i++) y=y*10+s4[i]-48;
}
if(s3[0]!='n' && s4[0]=='n') c=1;
if(s3[0]>='0' && s3[0]<='9' && s4[0]>='0' && s4[0]<='9' && x>y || s3[0]=='n' && s4[0]!='n' || rf){
if(!rf) sta[++top]=1,rf=1,sta2[top]=0;
else sta[++top]=0,sta2[top]=0;
}else{
sta[++top]=0;
if(c) Max+=c,sta2[top]=1;
}
sta1[top]=s2[0];
}else{
ans=max(ans,Max);
if(!top) ERR=1;
if(sta[top]) rf=0;
if(sta2[top]) Max--;
f[sta1[top--]]=0;
flor--;
}
}
if(top || ERR) printf("ERR\n");
else if(ans==0 && st[2]=='1' || ans==st[4]-48) printf("Yes\n");
else printf("No\n");
}
return 0;
}
```
by hanmo0321 @ 2019-02-27 18:58:31
数组开大点?
by crpboy @ 2019-02-27 19:05:25
感谢大佬,不过WA了……
我太菜了~~~~
```cpp
#include<bits/stdc++.h>
using namespace std;
char st[20],s1[20],s2[20],s3[20],s4[20];
int t,h,top,flor,max_fl,Max,sta[10005],ans,sta1[10005],sta2[10005];
bool ERR,f[97+26+5+10000],rf;
int length(char s[20]){
int ans;
for(int i=0;s[i];i++) ans++;
return ans;
}
int main(){
scanf("%d",&t);
while(t--){
scanf("%d%s",&h,st);
ERR=0;top=0;flor=0;max_fl=0;ans=0;Max=0;
for(int j=1;j<=h;j++){
scanf("%s",s1);
if(s1[0]=='F'){
scanf("%s%s%s",s2,s3,s4);
if(f[s2[0]]) ERR=1;
f[s2[0]]=1;
int x=0,y=0,c=0;flor++;
max_fl=max(max_fl,flor);
if(s3[0]>='0' && s3[0]<='9'){
int len=length(s3);
for(int i=0;i<len;i++) x=x*10+s3[i]-48;
}
if(s4[0]>='0' && s4[0]<='9'){
int len=length(s4);
for(int i=0;i<len;i++) y=y*10+s4[i]-48;
}
if(s3[0]!='n' && s4[0]=='n') c=1;
if(s3[0]>='0' && s3[0]<='9' && s4[0]>='0' && s4[0]<='9' && x>y || s3[0]=='n' && s4[0]!='n' || rf){
if(!rf) sta[++top]=1,rf=1,sta2[top]=0;
else sta[++top]=0,sta2[top]=0;
}else{
sta[++top]=0;
if(c) Max+=c,sta2[top]=1;
}
sta1[top]=s2[0];
}else{
ans=max(ans,Max);
if(!top) ERR=1;
if(sta[top]) rf=0;
if(sta2[top]) Max--;
f[sta1[top--]]=0;
flor--;
}
}
if(top || ERR) printf("ERR\n");
else if(ans==0 && st[2]=='1' || ans==st[4]-48) printf("Yes\n");
else printf("No\n");
}
return 0;
}
```
by hanmo0321 @ 2019-02-27 19:09:52