WA 33pts求调(玄关
查看原帖
WA 33pts求调(玄关
916276
b9113fced86a32cad0d8楼主2025/2/6 11:53
#include<bits/stdc++.h>
using namespace std;

int t;

int main(){
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		stack<unsigned long long> s;
		for(int i = 0;i < n;i++){
			string c;
			cin>>c;
			if(c == "push"){
				int x;
				cin>>x;
				s.push(x);
			}
			if(c == "pop"){
				if(s.empty()){
					cout<<"Empty"<<endl;
					continue;
				}
				s.pop();
			}
			if(c == "query"){
				if(s.empty()){
					cout<<"Anguei!"<<endl;
					continue;
				}
				cout<<s.top()<<endl;
			}
			if(c == "size"){
				cout<<s.size()<<endl;
			}
		}
	}
}

RT,代码如上

2025/2/6 11:53
加载中...