求助
查看原帖
求助
705498
duanfeitong楼主2022/9/25 09:39

样例过了但是0分全WA

#include<iostream>
using namespace std;
int a[1000005],topx=-1,topy=-1;
int x[1000005],y[1000005];
int t,n;

inline void push(int m,bool p)
{
	if(p)x[++topx]=m;
	else y[++topy]=m;
}

inline void pop(bool p)
{
	if(p)topx--;
	else topy++;
}

int size(bool p)
{
	if(p) return topx+1;
	else return topy+1;
}

int head(bool p)
{
	if(p)return x[topx];
	else return y[topy];
}

bool empty(bool p)
{
	if(p) return topx==-1;
	else return topy==-1;
}

int main()
{
	cin>>t;
	for(int tt=0;tt<t;tt++)
	{
		cin>>n;
		for(int i=0;i<n;i++)
			cin>>x[i];
		for(int i=0;i<n;i++)
			cin>>y[i];
		for(int i=0;i<n;i++)
		{
			push(x[i],1);
			if(head(1)==y[n-i-1])
			{
				pop(1); 
			} 
		}
//		if(!empty(1))
//		{
//			cout<<"No"<<endl;
//			continue;
//		}
		if(empty(1))
		{
			cout<<"Yes"<<endl;
		}
		else
			cout<<"No"<<endl;
		while(empty(1)) pop(1);
	}
	return 0;
}
2022/9/25 09:39
加载中...