66 WA on #3
查看原帖
66 WA on #3
1058749
King_and_Grey楼主2024/7/25 19:58
#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long
#define endl "\n"

int n,T;
stack <int> s;
string str;

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin >> T;
	for(int j = 1;j <= T;j++){
		cin >> n;
		for(int i = 1,x;i <= n;i++){
			cin >> str;
			if(str == "push"){
				cin >> x;
				s.push(x);
			}else if(str == "query"){
				if(s.empty()){
					cout << "Anguei!" << endl;
					continue;
				}
				cout << s.top() << endl;
			}else if(str == "pop"){
				if(s.empty()){
					cout << "Empty" << endl;
					continue;
				}
				s.pop();
			}else if(str == "size"){
				cout << s.size() << endl;
			}
		}
	}
	cout << endl;
	return 0;
}

小号关注

2024/7/25 19:58
加载中...