66分求调
查看原帖
66分求调
1208636
lwq0220楼主2024/9/7 15:13

66分求调

#include<bits/stdc++.h>
using namespace std;
unsigned long long t,n,f[1000005],r=0;
int main()
{
	cin>>t;
	while(t--){
		cin>>n;
		for(int i=1;i<=n;i++){
			string s;
			cin>>s;
			if(s=="push"){
				unsigned long long x;
				cin>>x;
				f[++r]=x; 
			}
			if(s=="pop"){
				if(r<=0){
					cout<<"Empty"<<endl;
				}
				else r--;
			}
			if(s=="query"){
				if(r<=0){
					cout<<"Anguei!"<<endl;
				}
				else{
					cout<<f[r]<<endl;
				}
			}
			if(s=="size"){
				cout<<r<<endl;
			}
		}
	}
}
2024/9/7 15:13
加载中...