全TLE
查看原帖
全TLE
972155
gjt6733楼主2023/5/21 09:59
#include<bits/stdc++.h>
using namespace std;
stack<int>s;
int main(){
	int n=0,x=0,a=0;
	string c;
	cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a;
        for(int j=1;j<=a;i++){
            cin>>c;
            if(c=="push"){
                cin>>x;
                s.push(x);
            }
            if(c=="pop"){
                if(s.size()!=0){
                    s.pop();  
                }else{
                    cout<<"Empty";
                }
            }
            if(c=="query"){
                if(s.size()!=0){
                  cout<<s.top()<<endl;  
                }else{
                    cout<<"Anguei!";
                }
            }
            if(c=="size"){
                cout<<s.size();
            }    
        }
    }
	return 0;
}
2023/5/21 09:59
加载中...