本文共 1368 字,大约阅读时间需要 4 分钟。
注意:
1、就算有语法错误也要将读入都读完。
code:
#include #include #include #include #include #include #include #include #include #include #define int long long #define INF 10000000000007#define maxn 100006 #define rep(i,a,b) for (int i=(a);i<=(b);++i)#define dep(i,a,b) for (int i=(a);i>=(b);--i)using namespace std; char tle[maxn],fx[maxn],fy[maxn];bool vis[maxn];int val[maxn],n;stack ss;stack s_;signed main(){ int t; cin>>t; while (t--) { cin>>n; cin>>(tle+1); memset(vis,0,sizeof(vis)); int flag=0,l=0; memset(val,0,sizeof(val)); rep(i,1,n) { char pan,nam; cin>>pan; int cnt=0; if (pan=='E') { if (ss.empty()) {flag=1;} else { int tmp=ss.top(); ss.pop(); if (tmp<0) cnt=0; else if (tmp>100000) cnt=val[l+1]+1; else cnt=val[l+1]; char wow=s_.top(); s_.pop(); vis[(int)wow]=0; val[l+1]=0; val[l]=max(val[l],cnt); l--; } } else { l++; cin>>nam; if (vis[(int)nam]) {flag=1;} vis[(int)nam]=1; s_.push(nam); cin>>(fx+1)>>(fy+1); int rfx=0,rfy=0,mul=1; dep(j,(int)strlen(fx+1),1) { if (fx[j]=='n') {rfx=INF;break;} rfx+=(fx[j]-'0')*mul; mul*=10; } mul=1; dep(j,(int)strlen(fy+1),1) { if (fy[j]=='n') {rfy=INF;break;} rfy+=(fy[j]-'0')*mul; mul*=10; } ss.push(rfy-rfx); } } if (flag||l!=0) {cout<<"ERR"<
转载于:https://www.cnblogs.com/bullshit/p/9933592.html