开了unsigned long long还是33分求调
查看原帖
开了unsigned long long还是33分求调
1411354
xf20280111楼主2025/2/7 13:58
#include<bits/stdc++.h>
#define int unsigned long long
using namespace std;
stack<int>sta;
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;cin >> t;
	while(t--){
		int n;cin >> n;
		while (!sta.empty()) {
        	sta.pop();
    	}
		for (int i = 1;i <= n;i++){
			string cz;cin >> cz;
			if (cz == "size") cout << sta.size() << "\n" ;
			else if (cz == "pop"){
				if (sta.empty()){
					cout << "Empty" << "\n"; 
				}
				else sta.pop();
			}
			else if (cz == "push"){
				long long x;cin >> x;
				sta.push(x);
			}
			else if (cz == "query"){
				if (sta.empty()){
					cout << "Anguei!" << "\n";
				}
				else{
					cout << sta.top() << "\n";
				}
			}
		}
	}
	return 0;
}
2025/2/7 13:58
加载中...