0分求助

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

lixinran2012 @ 2024-04-21 14:51:00

#include<bits/stdc++.h>
using namespace std;
long long a[100005],c,d,e;
bool f[100005]={true};
int main(){
    cin>>c;
    for(long long i=1;i<=c;i++){
        cin>>d;
        for(int j=1;j<=d;j++){
            cin>>a[j];
        }
        for(long long j=d;j>=1;j--){
            cin>>e;
            if(e!=a[j]&&f[i]!=true){
                f[i]=false;
            }else f[i]=true;
        }
    }
    for(int i=1;i<=c;i++){
        if(f[i]==false){
            cout<<"No"<<endl;
        }else cout<<"Yes"<<endl;
    }
    return 0;
}

总感觉有亿点奇怪··· ···


by FarmerDrone @ 2024-04-22 22:12:14

一组样例:
in:
1
3
1 2 3
2 1 3
out:
Yes


|