0pts求助!
查看原帖
0pts求助!
582601
Been_Drunk楼主2023/1/12 11:21
#include <bits/stdc++.h>
using namespace std;
int sta[100005],staout[100005];
int topp;
stack <int> stackk;
int main()
{
    int n,l;
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>l;
        for (int j=1;j<=l;j++)
        {
            cin>>sta[j];
        }
        for (int j=1;j<=l;j++)
        {
            cin>>staout[j];
        }
        topp=1;
        for (int j=1;j<=l;j++)
        {
            stackk.push(sta[j]);
            while (stackk.top()==staout[topp])
            {
                stackk.pop();
                topp++;
                if (stackk.empty())
                {
                    break;
                }
            }
        }
        if (stackk.empty())
            cout<<"YES"<<'\n';
        else
            cout<<"NO"<<'\n';
        while (!stackk.empty())
            stackk.pop();
    }
    system("pause");
    return 0;
}

样例过了,大佬帮我看看!

2023/1/12 11:21
加载中...