C++33pts恳求dalao帮助!
查看原帖
C++33pts恳求dalao帮助!
601747
xibaohe楼主2023/1/8 22:52

#1AC #2WA #3TLE

感激不尽!

#include<bits/stdc++.h>
using namespace std;

long long n;
long long a[1000005];

int main(){
long long t;
cin>>t;
while(t--)
{ 
    cin>>n;
    long long front=1,last=0,x;
    string s;
    while(n--)
    {	
    	cin>>s;
    	if(s=="push")
    	{
    		cin>>x;
    		a[++last]=x;
		}
		if(s=="pop")
		{
			if(front>last)
			cout<<"Empty"<<endl;
			else
			last--;
		}
		if(s=="query")
		{
			if(front>last)
			cout<<"Anguei!"<<endl;
			else
			cout<<a[last]<<endl;
		}
		if(s=="size")
		{
			cout<<last-front+1<<endl;
		}
	}
}
return 0;
}



2023/1/8 22:52
加载中...