33分求条

B3614 【模板】栈

Lamine_Linrui @ 2024-12-07 12:30:58

#include<bits/stdc++.h>
#define IO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int t,n,x;
string s;
int main(){
    IO;
    cin>>t;
    while(t--){
        stack<unsigned long long>sta;
        cin>>n;
        while(n--){
            cin>>s;
            //switch(s)
            //{
            if(s=="push"){
                cin>>x;
                sta.push(x);                
            }
                //break;
            if(s=="pop")
                if(sta.empty())cout<<"Empty\n";
                else sta.pop();
                //break;
            if(s=="query")
                if(sta.empty())cout<<"Anguei!\n";
                else cout<<sta.top()<<"\n";
                //break;
            if(s=="size")
                cout<<sta.size()<<"\n";
                //break;
            //}
        }
    }
    return 0;
}

by TLE_MLE_RE @ 2024-12-07 12:48:49

看下进食后人


|