(这总不能举报了吧)
  • 板块灌水区
  • 楼主haimingbei
  • 当前回复7
  • 已保存回复7
  • 发布时间2024/8/4 16:46
  • 上次更新2024/8/4 16:59:49
查看原帖
(这总不能举报了吧)
1235026
haimingbei楼主2024/8/4 16:46

对一个,WA一个,MLE一个(33分)

/*
1、B3614 【模板】栈 
*/
#include<bits/stdc++.h>
using namespace std;
stack <int> st;
int main(){
	int t,n,x;
	string s;
	cin>>t;
	for(int i=1;i<=t;i++){
		cin>>n;
		while(n--){
		cin>>s;
			if(s=="push"){
				cin>>x;
				st.push(x);
			}
			else if(s=="pop"){
				if(!st.empty())st.pop();
				else cout<<"Empty";
			}
			else if(s=="query"){
				if(!st.empty())cout<<st.top()<<endl;
				else cout<<"Anguei!"<<endl;
			}
			else if(s=="size")cout<<st.size()<<endl;
		}
	}
	
	return 0;
}
2024/8/4 16:46
加载中...