WA最后一个点
查看原帖
WA最后一个点
1145818
Eclipse_Devil楼主2024/4/27 14:38
#include <bits/stdc++.h>
using namespace std;
stack<string> s;
int o,n;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string x;
	cin >> o;
	string t;
	for(int i = 1;i <= o;i++){
		cin >> n;
    	for(int j = 1;j <= n;j++){
      		cin >> t;
      		if(t == "push"){
        		cin >> x;
				s.push(x);
      		}else if(t == "pop"){
        		if(s.empty()){
        			cout << "Empty" <<endl;
				}else{
					s.pop();
				}
			}else if(t == "query"){
        		if(s.empty()){
        			cout << "Anguei!" <<endl;
				}else{
					cout << s.top() <<endl;
				}
			}else{
				cout << s.size() <<endl;
			}
		}
	}
	
	return 0;
}
2024/4/27 14:38
加载中...