STL 40pts 求调
查看原帖
STL 40pts 求调
770910
ice_fish01楼主2023/3/3 23:26

我的代码:请求神犇支援qaq

#include<bits/stdc++.h>
using namespace std;
int a[100010],b[100000],n,q;
signed main()
{
	stack <int> s;
	cin >> q;
	while(q--)
	{
		cin >> n;
		for(int i = 1;i <= n;i++)
			cin >> a[i];
		for(int i = 1;i <= n;i++)
			cin >> b[i];
		int j = 1;
		for(int i = 1;i <= n;i++)
		{
			s.push(a[i]);
			if((s.top()) == b[j])
			{
				s.pop(); 
				j++;
				if(s.empty())
					break;
			}
		}
		if(s.empty())
			puts("Yes");
		else
			puts("No");
		while(!s.empty())
			s.pop();
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
	}
	return 0;
}

2023/3/3 23:26
加载中...