wa最后一个样例,求大佬帮助
查看原帖
wa最后一个样例,求大佬帮助
1109408
ruibo123456楼主2024/7/11 10:47
#include<bits/stdc++.h>
using namespace std;
stack<unsigned long long> s;
unsigned long long t,n;
int main()
{
	cin>>t;
	while(t--)
	{
		cin>>n;
		string s1;
		for(int i=0;i<n;i++)
		{
			while(!s.empty()) s.pop();
			unsigned long long x;
			cin>>s1;
			if(s1=="push")
			{
				cin>>x;
				s.push(x);
			}
			else if(s1=="pop")
			{
				if(!s.empty())
					s.pop();
				else
					cout<<"Empty"<<endl;
			}
			else if(s1=="query")
			{
				if(!s.empty())
					cout<<s.top()<<endl;
				else
					cout<<"Anguei!"<<endl;
			}
			else if(s1=="size")
			{
				cout<<s.size()<<endl;
			}
		}
	}
	return 0;
}
2024/7/11 10:47
加载中...