66分求助
查看原帖
66分求助
1200401
wnqnld_llx楼主2024/5/8 15:09

最后一个点WA

#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
stack<int> e;
signed main(){
	int t;
	cin>>t;
	for(int i=1;i<=t;i++){
		int n;
		cin>>n;
		for(int i=1;i<=n;i++){
			string in;
			cin>>in;
			if(in=="push"){
				int x;
				cin>>x;
				e.push(x);
			}
			if(in=="query"){
				if(!e.empty())
				cout<<e.top()<<"\n";
				
				else
				cout<<"Anguei!\n";
			}
			if(in=="size"){
				cout<<e.size()<<"\n";
			}
			if(in=="pop"){
				if(e.empty()) cout<<"Empty\n";
				else e.pop();
			}
		}
	}
	while(e.size()!=0) e.pop();
	return 0;
}
2024/5/8 15:09
加载中...