33pts求因
查看原帖
33pts求因
1125939
Yuexingfei_qwq楼主2024/7/7 10:36

后两个WA了,why?

#include <bits/stdc++.h>
#include <iostream>
#include <time.h>
#include <stdlib.h>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>

using namespace std;

int t, n, top = 0;
long long a[1000010];

int main() {
	scanf ("%d", &t);
	while (t--) {
		scanf ("%d", &n);
		top = 0;
		memset(a, 0, sizeof(a));
		while (n--) {
			char c[20];
			scanf ("%s", c);
			if (c[2] == 's') {
				long long x;
				scanf ("%lld", &x);
				a[++top] = x;
			} else {
				if (c[2] == 'p') {
					if (!top) {
						printf ("Empty\n");
					} else {
						top--;
					}
				} else {
					if (c[2] == 'e') {
						if (!top) {
							printf ("Anguei!\n");
						} else {
							printf ("%lld\n", a[top]);
						}
					} else {
						printf ("%d\n", top);
					}
				}
			}
		}
	}
	return 0;
}

3Q!

2024/7/7 10:36
加载中...