为什么TLE??
查看原帖
为什么TLE??
1288602
Xianyujunzhu楼主2024/7/21 18:21
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	cin>>t;
	stack<unsigned long long int> a;
	for(int i=1;i<=t;i++){
		int n;
		cin>>n;
		while(!a.empty()) a.pop();
		for(int j=1;j<=n;i++){
			string s;
			cin>>s;
			if(s=="push"){
				unsigned long long x;
				cin>>x;
				a.push(x);
			}
			else if(s=="pop"){
				if(a.empty()) cout<<"Empty"<<endl;
				else a.pop();
			}
			else if(s=="query"){
				if(a.empty()) cout<<"Anguei!"<<endl;
				else cout<<a.top();
			}
			else{
				cout<<a.size()<<endl;
			}
		}
	}
	return 0;
}
2024/7/21 18:21
加载中...