警示后人

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

liminghao666 @ 2023-09-03 15:39:59

#include<bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
int main(){
    int t;
    cin>>t;
    while(t--){
        stack<int>q;
        int n;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        for(int i=1;i<=n;i++){
            cin>>b[i];
        }
        int zxc=a[n+1]=b[n+1]=1;
        for(int i=1;i<=n;i++){
            q.push(a[i]);
            while(q.size()!=0&&b[zxc]==q.top()){
                zxc++;
                q.pop();
            }
        }
        if(q.size()>0){
            cout<<"NO\n";//这里
        }else{
            cout<<"YES\n";//还有这里
        }
    }
    return 0;
} 

大小写问题

No变NO,Yes变YES


by Gohidg @ 2023-09-03 16:04:03

@liminghao666 后人前来报到


by IOI_AK_TLR @ 2023-10-26 10:09:05

@liminghao666 %%%


|