求助一下P4387题---验证栈序列
我感觉应该没啥问题,可以数据全部WA了,实在没看出哪里的问题
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
using namespace std;
int q;
int main()
{
scanf("%d", &q);
while (q--)
{
int n;
scanf("%d", &n);
stack<int> in;
vector<int> out(n);
for (int i = 0; i < n; i++)
{
int x;
scanf("%d", &x);
in.push(x);
}
for (int i = 0; i < n; i++)
cin >> out[i];
for (int i = 0; i < n; i++)
{
if (out[i] == in.top())
in.pop();
else
{
cout << "No" << endl;
break;
}
}
if (in.empty())
cout << "Yes" << endl;
}
return 0;
}