题解 | 【模板】栈的操作
【模板】栈的操作
https://www.nowcoder.com/practice/cdf02ea916454957b575585634e5773a
res, n = [], int(input()) for i in range(n): ope = input().split(' ') if ope[0] == 'push': res.append(ope[1]) elif ope[0] == 'size': print(len(res)) elif len(res) != 0 and ope[0] == 'pop': res.pop() elif len(res) != 0 and ope[0] == 'query': print(res[-1]) else: print('Empty')