题目链接:
https://www.acwing.com/problem/content/830/
python3 代码
N=100010
stk=[0]*N
m=int(input())
tt=0
while m>0:
m-=1
a=input().split()
if a[0]=='push':
tt+=1
stk[tt]=a[1]
elif a[0]=='pop':
tt-=1
elif a[0]=='query':
print(stk[tt])
elif a[0]=='empty':
print('YES') if tt==0 else print('NO')