样例没过,9个WA1个TLE
查看原帖
样例没过,9个WA1个TLE
1432905
qiyiming楼主2025/7/25 10:02
#include<bits/stdc++.h>
using namespace std;
stack <int> st;
int t, n;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> t;
	while (t--) {
		cin >> n;
		while (n--) {
			string s;
			cin >> s;
			if (s == "Push") {
				int x;
				cin >> x;
				st.push(x);
			}
			else if (s == "pop") {
				if (!st.empty()) st.pop();
				else cout << "Empty" << endl;
			}
			else if (s == "query") {
				if (!st.empty()) cout << st.top() << endl;
				else cout << "Anguei!";
			}
			else if (s == "size") {
				cout << st.size();
			}
		}
	}
	while (!st.empty()) {
		cout <<st.top() << " ";
		st.pop();
	}
    return 0;
}
2025/7/25 10:02
加载中...