0分(悲
查看原帖
0分(悲
649751
Blued楼主2022/10/8 10:01

样例能过啊

#include<bits/stdc++.h>
#define int long long
#define ull unsigned long long
using namespace std;

stack <ull> a;

ull t,n,x;
string s;

signed main()
{
//	freopen("fun.in" , "r" , stdin);
//	freopen("fun.out" , "w" , stdout);
	cin >> t ;
	while(t--)
	{
		while(!a.empty())
		a.pop();
		cin >> n ;
		while(n--)
		{
			cin>>s;
			if(s=="push")
			{
				cin>>x;a.push(x);
			}
			else if(s=="pop")
			{
				if(!a.empty())
				a.pop();
				else
				printf("Empty\n");
			}
			else if(s=="query")
			{
				if(!a.empty())
				printf("%lld\n",a.top());
				else
				printf("Anguei!\n");
			}
			else
			printf("%d\n",a.size());
		}
	}
	return false;
}
2022/10/8 10:01
加载中...