求助
  • 板块灌水区
  • 楼主AnOIer
  • 当前回复1
  • 已保存回复1
  • 发布时间2023/10/11 14:48
  • 上次更新2023/11/2 14:30:27
查看原帖
求助
1036897
AnOIer楼主2023/10/11 14:48

题目

#include<bits/stdc++.h>
using namespace std;
const unsigned long long maxn=1e9;
char sta[maxn];
unsigned long long head=0;
int push(char n){
	sta[head]=n;
	head++;
}
int query(){
	if(head==0) cout<<"Anguei!\n";
	else cout<<sta[head-1]<<endl;
}
int size(){
	cout<<head<<endl;
}
int pop(){
	if(head==0) cout<<"Empty\n";
	else head-=1;
}
int main(){
	cin.tie(0);
  	ios::sync_with_stdio(false);
	unsigned long long n;
	string a;
	char b;
	cin>>n;
	unsigned long long m;
	for(int i=1;i<=n;i++){
		memset(sta,1e9,0);
		cin>>m;
		for(int j=1;j<=m;j++){
			cin>>a;
			if(a=="push") {
				cin>>b;
				push(b);
			}
			if(a=="query") query();
			if(a=="pop") pop();
			if(a=="size") size();
		}
	}
	return 0;
}

为什么2 RE,1 TLE?

2023/10/11 14:48
加载中...