Kalso42 @ 2023-10-31 21:46:06
#include <iostream>
#include <stack>
using namespace std;
int main()
{
int n;
cin >> n;
int answer[n];
for (int o = 0; o < n; ++o)
{
int m;
cin >> m;
stack<int> s;
for (int i = 0; i < m; ++i)
{
int x;
cin >> x;
s.push(x);
}
for (int j = 0; j < m; ++j)
{
int y;
cin >> y;
if (y == s.top())
{
if (s.size() > 1)
s.pop();
else
{
answer[o] = 1;
break;
}
}
else
{
answer[o] = 0;
break;
}
}
}
for (int p = 0; p < n; ++p)
{
cout << (answer[p] == 1 ? "Yes" : "No") << endl;
}
}
by Kalso42 @ 2023-10-31 22:09:45
@Ccm1225 是最后一个不用换行吗?可是我试过了也全WA
by Ccm1225 @ 2023-10-31 22:21:08
@Kalso42 刚刚看错了
真是非常抱歉。
题目的意思是push操作和pop操作可能会交错进行。
你可能会错意了
by Kalso42 @ 2023-10-31 22:31:50
@Ccm1225 谢谢我现在明白了