RE

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

Gohldg @ 2023-09-03 23:15:17

#include <bits/stdc++.h>
using namespace std;
int main(){
    int t,aa[114514],bb[114514],n,c[114514],xb;
    cin>>t;
    while(t--){
        stack<int>a;
        cin>>n,xb=1;
        for(int i=1;i<=n;i++)cin>>aa[i];
        for(int i=1;i<=n;i++)cin>>bb[i];
        for(int i=1;i<=n;i++){
            a.push(aa[i]);
            while(a.top()==bb[xb]&&!a.empty()){
                xb++,a.pop();
                if(xb>n)break;
            }
        }
        cout <<(!a.empty()?"No\n":"Yes\n");
    }
    return 0;
}

by y6hz @ 2023-09-10 22:05:35

极其糟糕的马蜂(看着好难受)


by y6hz @ 2023-09-10 22:07:31

@Gohldg 而且也不太可能这么水


by Gohldg @ 2023-09-10 22:16:12

@y6hz 压行压了点,我同学说很简单,然后我来常逝……


by y6hz @ 2023-09-12 06:45:36

@Gohldg hhh


by y6hz @ 2023-09-12 06:58:42

而且这复杂度都O(n^3)


by Gohldg @ 2023-09-12 22:22:33

@y6hz 但是是RE


by y6hz @ 2023-09-15 20:22:51

@Gohldg 数组太大或太小了?


|