33分求助!!!
查看原帖
33分求助!!!
1045961
穼柗°楼主2024/5/11 17:54

错的测试点都是 Too short on line 1.

#include <iostream>
#include <cstring>
#include <stack>
using namespace std;
signed main(void) {
	ios::sync_with_stdio(false),
	cin.tie(nullptr),
	cout.tie(nullptr);
	stack<int> st;
	string s;
	int n,x,T;
	for(cin>>T;T;T--) {
		while(st.size()) st.pop();
		for(cin>>n;n;n--) {
			cin>>s;
			if(s=="push") {cin>>x;st.push(x);}
			else if(s=="size") cout<<st.size()<<'\n';
			else if(st.empty()) cout<<(s=="pop"?"Empty\n":"Anguei!\n");
			else if(s=="pop") st.pop();
			else if(s=="query") cout<<st.top()<<'\n';
		}
	}
	return 0;
}
2024/5/11 17:54
加载中...