0分求助!! 呜呜呜,自己运行感觉没什么问题

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

aragorn133 @ 2022-12-30 16:43:48

#include<iostream>
#include<stack> 
using namespace std; 
const int N=1e5+10; 
int a[N];
stack<int>num;
int n,q,x,res;
int main()
{
    cin>>q;
    for(int i=0;i<q;i++)
    {
        cin>>n;
        for(int j=0;j<n;j++)
        {
            cin>>x;
            num.push(x);
        }
        for(int j=0;j<n;j++) cin>>a[i];

        while(num.size()!=0)
        {
            int t=num.top();
            int cnt=0;
            res=0;
            if(t!=a[cnt]) break;
            else
            {
                num.pop();
                res++;
                cnt++;
            }
        }
        if(res==n) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        while(num.size()!=0)num.pop();
    }
}

by Eureal_qwq @ 2022-12-30 16:58:13

第19行输入改成for(int j=0;j<n;j++) cin>>a[j];


by aragorn133 @ 2023-01-03 14:40:43

@Wendy 啊,抱歉这两天没看到消息,刚才改成j试了一下,还是0分,呜呜


|