66分求调
查看原帖
66分求调
1328532
Tmc2012楼主2024/8/17 10:16
#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long
const int N=1e6+10;
int T,n;
stack<int>t;
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>T;
	while(T--)
	{
		cin>>n;
		for(int i=1;i<=n;i++)
		{
			string s;
			cin>>s;
			if(s=="push")
			{
				int sum;
				cin>>sum;
				t.push(sum);
			}
			if(s=="pop")
			{
				if(t.empty())
				{
					cout<<"Empty"<<endl;
					continue;
				}
				t.pop();
			}
			if(s=="query")
			{
				if(t.empty())
				{
					cout<<"Anguei!"<<endl;
					continue;
				}
				cout<<t.top()<<endl;
			}
			if(s=="size")
			{
				cout<<t.size()<<endl;
			}
		}
	}
	return 0;
}

2024/8/17 10:16
加载中...