最后一点WA
查看原帖
最后一点WA
939955
chatGPS楼主2023/5/26 14:01

我的队列开的是string类型, 试过long long, 但不对, 没有TLE, 麻烦各位网友帮忙看看, 非常感谢.


#include <bits/stdc++.h>
using namespace std;
stack<string>s;
int main(){
	int t;
	cin >> t;
	while(t--){
		int n;
		cin >> n;
		while(n--){
			string a;
			cin >> a;
			if(a == "push"){
				string x;
				cin >> x;
				s.push(x);
			}else if(a == "pop"){
				if(s.empty()) {
					cout << "Empty" << endl;
				}
				else s.pop();
			}else if(a == "query"){
				if(s.empty()){
					cout << "Anguei!" << endl;
				}else cout << s.top() << endl;
			}else if(a == "size"){
				cout << s.size() << endl;
			}
		}
	}
	return 0;
}
2023/5/26 14:01
加载中...