1 条题解

  • 0
    @ 2026-4-10 11:32:33
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
    
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	int T, n;
    	for (cin >> T; T; --T)
    	{
    		stack<unsigned long long> stk;
    		for (cin >> n; n; --n)
    		{
    			string s;
    			cin >> s;
    			if (s == "push")
    			{
    				unsigned long long x;
    				cin >> x;
    				stk.push(x);
    			}
    			else if (s == "pop")
    			{
    				if (stk.empty())
    					cout << "Empty\n";
    				else
    					stk.pop();
    			}
    			else if (s == "query")
    			{
    				if (stk.empty())
    					cout << "Anguei!\n";
    				else
    					cout << stk.top() << '\n';
    			}
    			else
    			{
    				cout << stk.size() << '\n';
    			}
    		}
    	}
    	return 0;
    }
    
    
    • 1

    信息

    ID
    11528
    时间
    1000ms
    内存
    512MiB
    难度
    7
    标签
    递交数
    99
    已通过
    20
    上传者