一AC一WA一TLE,求因
查看原帖
一AC一WA一TLE,求因
1311985
chasm_pain楼主2024/7/2 14:52
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	unsigned long long t;
	cin>>t;
	while(t--)
	{
		stack<unsigned long long> a;
		string s;
		long long n,x;
		cin>>n;
		while(n--)
		{
			cin>>s;
			if(s=="push")
			{
				cin>>x;
				a.push(x);
			}
			if(s=="pop")
				if(a.size()!=0) a.pop();
				else cout<<"Empty"<<endl;
			if(s=="query")
				if(a.size()!=0) cout<<a.top()<<endl;
				else cout<<"Anguei!"<<endl;
			if(s=="size")
				cout<<a.size()<<endl;
		}
		while(a.size()>0){
			a.pop();
		}
	}
	return 0;
}
2024/7/2 14:52
加载中...