0分求调
查看原帖
0分求调
989997
DGL__DGL_AFO楼主2024/3/17 19:53

TWT,蒟蒻哭泣

用数组模拟的栈,样例能过

#include<bits/stdc++.h>
using namespace std;
unsigned long long  t,n,x,i,j=1;
char a[11];
unsigned long long s[1145141];

int main()
{
	cin>>t;
	
  while(t--)
  {
  	memset(s,0,sizeof s);
  	
  	scanf("%d",&n);
  	while(n--)
  	{
  		cin>>a;
  		if(a[2]=='s')
  	  {
  	  	i++;
  		  scanf("%lld",&x);
  		  s[i]=x;
  		  
		  }
  	  else if(a[2]=='p')
  	  {
  		  if(i<j)
  		    cout<<"Empty"<<endl;
  	  	else  
  		    j++;
	  	}
		  else if(a[2]=='e')
		  {
			  if(i<j)
			    cout<<"Anguei!"<<endl;
	  		else 
			    printf("%lld\n",s[i]);  
		  }
		  else
		    printf("%d\n",i-j+1);
	  	}	
	  }
	
	
	
	return 0;
} 
2024/3/17 19:53
加载中...