求助
查看原帖
求助
538392
Juruoviet楼主2022/6/23 19:11

第二个数据点就WA了,贴上代码

#include <iostream>
#include <string>
#include <stack>
#include <cstdio>
using namespace std;
int main() {
    int T, n;
    for (cin >> T; T; --T) {
        stack<long long> s;
        for (cin >> n; n; --n) {
            string t;
            cin >> t;
            if (t == "push") {
                unsigned long long x;
                cin >> x; s.push(x);
            } else if (t == "pop") {
                if (s.empty()) 
                cout << "Empty\n";
                else s.pop();
            } else if (t == "query") {
                if (s.empty()) 
                cout << "Anguei!\n";
                else cout << s.top() << '\n';
            } else {
                cout << s.size() << '\n';
            }
		}
	}
    return 0;
}
2022/6/23 19:11
加载中...