33pts求助
查看原帖
33pts求助
1277642
rui000楼主2024/7/2 14:51

1AC,1WA,1TLE 实在找不出来了。

#include<bits/stdc++.h>
using namespace std;
int main(){
	long long t;
	cin>>t;
	while(t--){
		stack<long long> st;
		string a;
		long long n,m;
		cin>>n;
		while(n--){
			cin>>a;
			if(a=="push"){
				cin>>m;
				st.push(m);
			}
			if(a=="pop"){
				if(st.size()!=0) st.pop();
				else cout<<"Empty"<<endl;
			}	
			if(a=="query"){
				if(st.size()!=0) cout<<st.top()<<endl;
				else cout<<"Anguei!"<<endl;
			}
			if(a=="size"){
				cout<<st.size()<<endl;
			}
		}
	}
	return 0;
}

蒟蒻题解看不懂

2024/7/2 14:51
加载中...