c++代码tle,很急,在线等
查看原帖
c++代码tle,很急,在线等
1395986
vscdr_楼主2024/7/14 21:05
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t; cin >> t;
	while (t--)
	{
		stack<unsigned long long> stk;
		int n; cin >> n;
		string s;
		while (n-- && cin >> s)

		{
			if (s == "push") {
				int x; cin >> x;
				stk.push(x);
			}
			else if (s == "query")
			{
				cout << stk.top();
				cout << '\n';
			}
			if (stk.empty() && s == "query") cout << "Anguei!" << '\n';
			else if (s == "size")
			{     
				cout << stk.size() << '\n';
			}
			else if (s == "pop")
			{
				stk.pop();
			}
			if (s.empty() && s == "pop")
			{
				cout << "Empty" << '\n';
			}
		}
	}

	return 0;
}
2024/7/14 21:05
加载中...