1 条题解

  • 1
    @ 2026-10-24 15:51:02
    #include<bits/stdc++.h>
    #define int unsigned long long
    using namespace std;
    signed main()
    {
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	cout.tie(0);
    	int t;
    	cin>>t;
    	while(t--)
    	{
    		int n;
    		cin>>n;
    		stack<int>st;
    		while(n--)
    		{
    			string s;
    			cin>>s;
    			if(s=="push")
    			{
    				int x;
    				cin>>x;
    				st.push(x);
    			}
    			if(s=="pop")
    			{
    				if(st.empty())
    				{
    					cout<<"Empty\n";
    				}
    				else st.pop();
    			}
    			if(s=="query")
    			{
    				if(st.empty())
    				{
    					cout<<"Anguei!\n";
    				}
    				else cout<<st.top()<<endl;
    			}
    			if(s=="size")
    			{
    				cout<<st.size()<<endl;
    			}
    		}
    	}
    } 
    
    • 1

    信息

    ID
    3202
    时间
    1000ms
    内存
    256MiB
    难度
    7
    标签
    递交数
    71
    已通过
    17
    上传者