求助!前两个WA后一个TLE
查看原帖
求助!前两个WA后一个TLE
691024
Qingshui_King楼主2023/3/2 13:16
#include<bits/stdc++.h>
using namespace std;
const int N=1000001;
long long stl[N],tt=0,T,n,x;
int main(){
	cin>>T;
	while(T--){
		memset(stl,0,sizeof(stl));
		tt=0;
		cin>>n;
		while(n--){
			string op;
			cin>>op;
			if(op=="push"){
				cin>>x;
				stl[++tt]=x;
			}
			else if(op=="pop"){
				if(tt>0)tt--;
				else cout<<"Empty"<<endl;
			}
			else if(op=="query"){
				if(tt>0)cout<<stl[tt]<<endl;
				else cout<<"Amguei!"<<endl;
			}
			else{
				cout<<tt<<endl;
			}
		}
	}
}
2023/3/2 13:16
加载中...