求助27pts WA on #4~10
查看原帖
求助27pts WA on #4~10
541634
littlebug楼主2023/10/1 03:51
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<algorithm>
#define il inline
#define mx 1e9
using namespace std;
struct func
{
	bool d; //是否封禁 
	int k; //层数 
};
int T;
int l;
string o;
bitset <300> used;
stack <func> fcs;
char fe;
char fi;
int x,y;
int w;
bool err;
il void read(int &x)
{
	char c=getchar();
	if(c=='n')
	{
		x=-1;
		return;
	}
	x=c-48;
	while((c=getchar())>=48 && c<=57) x=x*10+c-48;
	return;
}
il bool check(string s,int x)
{
	int ans;
	if(s.size()==6)
		ans=s[4]-48;
	else
		ans=(s[4]-48)*10+s[5]-48;
	return ans==x;
}
int main()
{
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin>>T;
	while(T--)
	{
		cin>>l>>o;
		used=0;
		w=0;
		err=0;
		while(fcs.size()) fcs.pop();
		for(int i=0;i<l;++i)
		{
			cin>>fe;
			if(fe=='F')
			{
				cin>>fi; getchar();
				read(x); read(y);
				if(err)
					continue;
				if(used[fi])
				{
					err=1;
					continue;
				}
				used[fi]=1;
				if(fcs.empty())
				{
					fcs.push( (func){0,0} );
				}
				else
				{
					if(fcs.top().d)
					{
						fcs.push( (func){1,fcs.top().k} );
						continue;
					}
					fcs.push( (func){0,fcs.top().k} );
				}
				if(x==-1 && y==-1)
					continue;
				if(x!=-1 && y==-1)
					++fcs.top().k;
				else if(x==-1 && y!=-1)
					fcs.top().d=1;
				else if(x>y)
					fcs.top().d=1;
			}
			else
			{
				if(err)
					continue;
				if(fcs.empty())
				{
					err=1;
					continue;
				}
				w=max(w,fcs.top().k);
				fcs.pop();
			}
		}
		if(err || fcs.size())
			cout<<"ERR\n";
		else
		{
			if(o.size()==4)
			{
				if(w==0)
					cout<<"Yes\n";
				else
					cout<<"No\n";
			}
			else
			{
				if(check(o,w))
					cout<<"Yes\n";
				else
					cout<<"No\n";
			}
		}
	}
	return 0;
}
2023/10/1 03:51
加载中...