66分求调
查看原帖
66分求调
772814
cza2023楼主2023/12/15 12:42
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
stack<int> st;
signed main(){
	int n;
	cin>>n;
	while(!st.empty()){st.pop();}
	for(int i=1;i<=n;i++){
		int cs;
		cin>>cs;
		for(int j=1;j<=cs;j++){
			string cz;
			int ps;
			cin>>cz;
			if(cz=="push")cin>>ps,st.push(ps);
			if(cz=="query"){
				if(st.empty())cout<<"Anguei!"<<endl;
				else cout<<st.top()<<endl;
			}
			if(cz=="pop"){
				if(st.empty())cout<<"Empty"<<endl;
				else st.pop();
			}
			if(cz=="size")cout<<st.size()<<endl;
		}
	}
}
2023/12/15 12:42
加载中...