33分,求调
查看原帖
33分,求调
1391560
chentonghe楼主2025/2/7 20:12
#include<bits/stdc++.h>

using namespace std;

stack <unsigned long long> st;

int main()
{

	int T;
  
	cin >> T;
  
	while(T--)
  
	{
  
		int n;
    
		cin >> n;
    
		for(int i = 1; i <= n; i++)
    
		{
    
			string s;
      
			cin >> s;
      
			if(s == "push")
      
			{
      
				long long x;
        
				cin >> x;
        
				st.push(x);
        
			}
      
			if(s == "pop")
      
			{
      
				if(st.empty())
        
				{
        
					cout << "Empty\n";
          
					continue;
          
				}
        
				st.pop();
        
			}
      
			if(s == "query")
      
			{
      
				if(st.empty())
        
				{
        
					cout << "Anguei!\n";
          
					continue;
          
				}
        
				cout << st.top() << endl;
        
			}
      
			if(s == "size")
      
			{
      
				cout << st.size() << endl;
        
			}
      
		}
    
	}
  
	return 0
  ;
}
2025/2/7 20:12
加载中...