WA on 1 2 3 4 5,蒟蒻求调
查看原帖
WA on 1 2 3 4 5,蒟蒻求调
578004
02Ljh楼主2022/5/13 19:32
#include <bits/stdc++.h>
using namespace std;
int xy[114514];
bool flag[114514];
stack <int> q;
bool work(int n)
{
	while(!q.empty()) { q.pop(); }
	memset(xy,0,sizeof(xy));
	fill(flag,flag+114514,false);
	int l,pos=0;
	for(int i=0;i<n;i++)
	{
		cin>>xy[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>l;
		q.push(l);
		//cout<<pos<<endl;
		if(l==xy[pos])
		{
			while(!q.empty()&&xy[pos]==q.top())
			{
				if(!q.empty()&&xy[pos]==q.top())
				{
					//cout<<q.top()<<" "<<o<<endl;
					pos++;
					q.pop();
				}
				else
				{
					break;
				}				
			}
			//cout<<pos<<endl;
		}
	}
	if(q.empty()) return true;
	else return false;
}
int main()
{
    int t,n;
    cin>>t;
    for(int i=0;i<t;i++)
	{
		cin>>n;
		if(work(n)) puts("Yes");
		else puts("No");
	}
	return 0;
}
/*
1
3
1 2 3
2 1 3
*/
2022/5/13 19:32
加载中...