样例过了但是WA 求调
查看原帖
样例过了但是WA 求调
588872
LeNotFound楼主2022/3/23 20:52
#include<bits/stdc++.h>

using namespace std;

inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(!isdigit(ch))
    {
        if(ch=='-')
        {
            f=-1;
        }
        ch=getchar();
    }
    while(isdigit(ch))
    {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

typedef long long ll;

ll T;

vector<ll> a;

int main()
{
    T=read();
    
    for (ll i = 0; i < T; i++)
    {
        ll n=read();
        for (ll j = 0; j < n; j++)
        {
            string op;
            cin>>op;
            if(op=="push")
            {
                a.push_back(read());
            }
            else if(op=="pop")
            {
                if(a.empty())
                {
                    cout<<"Empty"<<endl;
                }
                else 
                {
                    a.pop_back();
                }
            }
            else if(op=="query")
            {
                if(!a.empty())
                {
                    cout<<a.back()<<endl;
                }
                else 
                {
                    cout<<"Anguei!"<<endl;
                }
            }
            else if(op=="size")
            {
                cout<<a.size()<<endl;
            }
        }
    }
    
    // Debug
    // int Debuger=0;
    // cin>>Debuger;
    return 0;
}

代码如上

2022/3/23 20:52
加载中...