救救33分的蒟蒻(求助)
查看原帖
救救33分的蒟蒻(求助)
858362
tianpengbattle楼主2024/4/10 21:40
#include <bits/stdc++.h>
using namespace std;
stack < unsigned long long > q;
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		int x; cin >> x;
		for(int j = 1; j <= x; j++)
		{
			string s; cin >> s;
			if(s == "push")
			{
				int y; cin >> y;
				q.push(y);
			}
			if(s == "query")
				if(!q.empty()) cout << q.top() << endl;
				else cout << "Anguei!" << endl;
			if(s == "pop")
				if(!q.empty()) q.pop();
				else cout << "Empty" << endl;
			if(s == "size")
				cout << q.size() << endl;
		}
		while(!q.empty()) { q.pop(); }
	}
	return 0;
}
2024/4/10 21:40
加载中...