#include<bits/stdc++.h> using namespace std; int main() { unsigned long long t, n, x; cin >> t; for(unsigned long long i = 1; i <= t; i++) { cin >> n; stack st; for(int j = 1; j <= n; j++) { string s; cin >> s;

		if(s == "push") {
			cin >> x;
			st.push(x);
		} else if(s == "pop") {
			if(st.empty()) {
				cout << "Empty" << endl;
			} else {
				st.pop();
			}
		} else if(s == "query") {
			if(st.empty()) {
				cout << "Anguei!" << endl;
			} else {
				cout << st.top() << endl;
			}
		} else if(s == "size") {
			cout << st.size() << endl;
		}
	}
}

return 0;

}

0 条评论

目前还没有评论...

信息

ID
1966
时间
ms
内存
MiB
难度
2
标签
递交数
246
已通过
48
上传者