0ptsWA求调
查看原帖
0ptsWA求调
1050484
Netherite_Pickaxe楼主2024/7/16 10:16

rt , 代码如下

#include<bits/stdc++.h>
using namespace std;
stack<int> stk;
inline void setup()
{
	int t;
	int n;
	string s;
	int p;
	scanf("%d",&t);
	for(int i=1;i<=t;i+=1)
	{
		scanf("%d",&n);
		for(int j=1;j<=n;j+=1)
		{
			cin>>s;
			if(s=="push")
			{
				scanf("%d",&p);
				stk.push(p); 
			}
			if(s=="pop")
			{
				if(stk.empty())
				printf("Empty\n");
				else
				stk.pop();
			}
			if(s=="query")
			{
				if(stk.empty())
				printf("Anguei!\n");
				else
				printf("%d",stk.top());
			}
			if(s=="size")
			printf("%d\n",stk.size());
		}
	}
}
signed main()
{
	setup();
	exit(0);
}
2024/7/16 10:16
加载中...