WA#1 求调
查看原帖
WA#1 求调
1296159
yscxk264楼主2024/6/21 20:02
#include <iostream>
#include <stack>
using namespace std;
stack <unsigned long long> m;
int main() {
	unsigned long long t, n;
	cin >> t >> n;
	for (int i = 1; i <= t; i++) {
		for (int j = 1; j <= n; j++) {
			string s;
			unsigned long long x;
			cin >> s;
			if (s == "push") {
				cin >> x;
				m.push(x);
			}
			else if (s == "pop" && m.empty()) cout << "Empty" << endl;
			else if (s == "pop") m.pop();
			else if (s == "query" && m.empty()) cout << "Anguei!" << endl;
			else if (s == "query") cout << m.top() << endl;
			else if (s == "size") cout << m.size() << endl;
		}
	}
	return 0;
}
2024/6/21 20:02
加载中...