求大佬找错,只能过样例
查看原帖
求大佬找错,只能过样例
406075
Qimu47楼主2022/8/10 14:22
#include <bits/stdc++.h>

#define x first
#define y second

using namespace std;

typedef unsigned long long int ull;
const int N = 1e6 + 10;

ull stk[N];
int tt=-1;

void push(int x)
{
    stk[++tt]=x;
}

void pop()
{
    if(tt==-1) cout<<"Empty"<<endl;
    else
        tt--;
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int t;
    cin>>t;
    while(t--)
    {
        memset(stk,-1,sizeof stk);
        tt=-1;
        int n;
        cin>>n;
        while(n--)
        {
            string op;
            cin>>op;
            if(op=="push") 
            {
                ull x;
                cin>>x;
                push(x);
            }
            else if(op=="query")
            {
                if(tt>-1)
                    cout<<stk[tt]<<endl;
                else cout<<"Anguei!"<<endl;
            }
            else if(op=="size")
            {
                cout<<tt+1<<endl;
            }
            else 
            {
                pop();
            }
        }
    }
    return 0;
}

2022/8/10 14:22
加载中...