最后一个测试点过不去(求大佬帮忙)
查看原帖
最后一个测试点过不去(求大佬帮忙)
1197548
YYZK楼主2024/3/21 21:49
#include<bits/stdc++.h>
using namespace std;
int main(){
    unsigned long long T,n,x;
    unsigned long long i,j;
    string ch;
    cin>>T;
    stack<unsigned long long> c;
    for(i=0;i<T;i++){
    	cin>>n;
    	for(j=0;j<n;j++){
    		cin>>ch;
    		if(ch=="push"){
    			cin>>x;
    			c.push(x);
			}
			if(ch=="pop"){
				if(c.empty()==1){
					cout<<"Empty"<<endl;
				}else{
					c.pop();
				}	
			}
			
			if(ch=="query"){
				if(c.empty()==1){
					cout<<"Anguei!"<<endl;
				}else{
					cout<<c.top()<<endl;
				}
			}
			
			if(ch=="size"){
				cout<<c.size()<<endl;
			}
			
		}
	}
    
    return 0;
}
2024/3/21 21:49
加载中...