Files
python/TangDou/AcWing/Stack/828.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

27 lines
557 B
C++

#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int stk[N], tt;
int main() {
string op;
int n;
cin >> n;
while (n--) {
cin >> op;
if (op == "push") {
int x;
cin >> x;
stk[++tt] = x;
} else if (op == "pop")
tt--;
else if (op == "query")
printf("%d\n", stk[tt]);
else if (op == "empty") {
if (tt == 0) printf("YES\n");
else printf("NO\n");
}
}
return 0;
}