B3614求调
  • 板块题目总版
  • 楼主Special_Gao
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/3/18 22:09
  • 上次更新2024/3/19 12:52:49
查看原帖
B3614求调
1003923
Special_Gao楼主2024/3/18 22:09

66分QWQ代码求调

#include <iostream>
#include <stack>
using namespace std;
typedef unsigned long long ull;
stack<ull> st;
ull t;
int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> t;
	for(ull i = 1; i <= t; i++) {
		ull n;
		cin >> n;
		for(ull j = 1; j <= n; j++) {
			string s;
			cin >> s;
			if(s == "push") {
				ull x;
				cin >> x;
				st.push(x);
			}
			if(s == "pop") {
				if(st.empty())
					cout << "Empty" << endl;
				else st.pop();
			}
			if(s == "query") {
				if(st.empty())
					cout << "Anguei!" << endl;
				else
					cout << st.top() << endl;
			}
			if(s == "size")
				cout << st.size() << endl;
			}
	}
	return 0;
}
2024/3/18 22:09
加载中...