1 條題解

  • 1
    @ 2026-10-24 15:52:23
    #include<bits/stdc++.h>
    #define int long long
    using namespace std;
    signed main()
    {
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	cout.tie(0);
    	int t;
    	cin>>t;
    	queue<int>q; 
    	while(t--)
    	{
    		int op;
    		cin>>op;
    		if(op==1)
    		{
    			int x;
    			cin>>x;
    			q.push(x);
    		}
    		if(op==2)
    		{
    			if(q.empty())
    			{
    				cout<<"ERR_CANNOT_POP\n";
    			}
    			else q.pop();
    		}
    		if(op==3)
    		{
    			if(q.empty())
    			{
    				cout<<"ERR_CANNOT_QUERY\n";
    			}
    			else cout<<q.front()<<endl;
    		}
    		if(op==4)
    		{
    			cout<<q.size()<<endl;
    		}
    	}
    } 
    

    資訊

    ID
    3203
    時間
    1000ms
    記憶體
    256MiB
    難度
    5
    标签
    遞交數
    22
    已通過
    14
    上傳者