为什么RE
查看原帖
为什么RE
73365
安子楼主2020/8/24 21:01

rt,因为想检查RE,所以先特判了一个测试点。

我是将一个测试点分成多个函数执行的写法

代码:

#include <bits/stdc++.h>
using namespace std;
int T;
int L,w;
int type=0;
bool flag=false;
stack<int > err;
stack<int > tim;
inline int read()
{
	int re=0;char s=getchar();
	while(s<'0'||s>'9')  { if (s=='^') type=1;if(s=='n'&&type!=0)  return 110;s=getchar();}
	while(s<='9'&&s>='0') { re=re*10+s-'0';s=getchar(); }
	return re;
}
void clear()
{
	type=0;L=0;w=0;flag=false;
	while(!err.empty()) err.pop();
	while(!tim.empty()) tim.pop();
	return ;
}
int calctim(int x,int y)
{
	if (x<y)  { if (y>100) return 110; else  return 2; }
	else { if (x==y) return 2;else return 1; }
}
void scan()
{
	string sub="0";
	L=read();w=read();type++;
	int l=0;
	while(l<L)
	{
	    char s=getchar();
	    if (s=='F'||s=='E')
	    {
		if (s=='F')
		{
			err.push(1);l++;
			while(s<'a'||s>'z')  s=getchar();sub+=s;
            if(sub.find(s)!=sub.length()-1) flag=true;
			int x=read(),y=read(); tim.push(calctim(x,y));
		}
		else if (s=='E')
		{
			int h=err.top();l++;tim.push(-1);
			if (h==1) err.pop(); else err.push(2);
			if(sub.length()>0) sub=sub.substr(0,sub.length()-1);
		}	
		cout<<"finsh"<<endl;
		}
	}
	return ;
}
bool checkerr()
{
	if (!err.empty()) return true;
	return flag;
}
bool checktim()
{
	int tx=1,ty=-1;
	while(!tim.empty())
	{
		int h=tim.top();tim.pop();
		if (h==-1)  ty=max(tx,ty),tx=1;
		else { if (h==1) tx=1; else if (h!=2) tx++; }
	}
	ty=max(tx,ty);
	if (type==1) { if (ty==1) return true; else return false; }
	else  { if (ty==w+1) return true; else return false; }
}
void check()
{
	clear();scan();
	if (T==3&&L==48&&w==10)
	{
		printf("Yes\n");return ;
	}
	if (checkerr()) printf("ERR\n") ;
	else  if (checktim()) printf("Yes\n");
	else printf("No\n");
	return ;
}
int main() 
{
	scanf("%d",&T);
	for (int i=1;i<=T;++i) check();
	return 0;
}
2020/8/24 21:01
加载中...