求助!!!

P4387 【深基15.习9】验证栈序列

zzx12321 @ 2024-12-24 19:04:09

求助QWQ!

#include<bits/stdc++.h>
using namespace std;
long long s,a,d;
deque<int> q,w;
int shu[100010],chu[100010];
int main(){
    cin>>s;
    for(int i=0;i<s;i++){
        while(!q.empty()){
            q.pop_front();
        }
        cin>>a;
        for(int j=0;j<a;j++){
            cin>>d;
            q.push_back(d);
        }
        bool flag=0;
        for(int j=0;j<a;j++){
            cin>>chu[j];

            if(q.back()!=chu[j]){
                flag=1;
                break;
            }
            q.pop_back();
        }
        if(flag==0){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}

|