67分求助2#TLE
查看原帖
67分求助2#TLE
495376
Alan0518楼主2023/8/26 10:45
#include<bits/stdc++.h>
using namespace std;
stack<string>s;
int main()
{
long long  t,n;
cin>>t;

	while(n--){
		cin>>n;
while(s.size())s.pop();
for(int i=1;i<=n;i++){
	string st;cin>>st;
	if(st=="push"){
	string x;cin>>x;
	s.push(x);
}
	if(st=="query"){
	if(!s.empty())cout<<s.top()<<endl;
	else cout<<"Anguei!"<<endl;
}
	if(st=="size"){
	cout<<s.size()<<endl;
}
	if(st=="pop"){
	if(s.empty())cout<<"Empty"<<endl;
	else s.pop();
			}
		}
	}
    return 0;
}

不知道为什么会超时

2023/8/26 10:45
加载中...