测试点3没过求助
查看原帖
测试点3没过求助
1060846
wangziyuan123楼主2024/1/21 17:51
#include<bits/stdc++.h>

using namespace std;
const int N=1000100;
unsigned long long int st[N];
long long tt;
int t;
int n;

void push(unsigned long long int x)
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	st[++tt]=x;
}
void pop()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	if(tt<=0)cout<<"Empty"<<endl;
	else 
	{
		tt--; 
	} 
}
void query()
{
ios::sync_with_stdio(0);
    cin.tie(0);
	if(tt<=0)
	{	
	cout<<"Anguei!"<<endl;
    }
	else
	{
	cout<<st[tt]<<endl; 
	}
} 
void size()
{
ios::sync_with_stdio(0);
    cin.tie(0);
	if(tt>=0)cout<<tt<<endl;
	else
	{
		cout<<"0"<<endl;
	}
}
int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	cin>>t;
	while(t--){
		cin>>n;
		while(n--)
		{
			string str;
			cin>>str;
			if(str=="push"){
				unsigned long long int x;
				cin>>x;
				push(x);
			}
			else if(str=="pop"){
				pop();
			}
			else if(str=="query"){
				query();
			}
			else
			{
				size();
			}
		}
	}
	return 0; 
} 
2024/1/21 17:51
加载中...