data740 @ 2024-09-09 13:24:19
#include<iostream>
#include<stack>
using namespace std;
stack<int>n;
int main()
{
int cnt;
cin >> cnt;
while (cnt--)
{
int flag = 1;
int num;
cin >> num;
for (int i = 0; i < num; i++)
{
int j;
cin >> j;
n.push(j);
}
for (int i = num - 1; i >= 0; i--)
{
int ans;
cin >> ans;
if (ans == n.top())n.pop();
else
{
cout << "No" << endl;
flag = 0;
break;
}
}
if (flag)cout << "Yes" << endl;
}
}
by xixiyan @ 2024-09-09 13:30:29
考虑输入
1
5
1 2 3 4 5
3 4 5 2 1
应该输出 Yes
但你的程序会输出 No
求个关
by xixiyan @ 2024-09-09 13:30:42
@data740