题解 | #矩阵乘法计算量估算#
矩阵乘法计算量估算
https://www.nowcoder.com/practice/15e41630514445719a942e004edc0a5b
n = int(input()) ls = [] for i in range(n): ls.append(list(map(int,input().split()))) s = input() # (A(BC)) stack = [] cc = 0 for i in s: if i.isalpha(): stack.append(ls[ord(i)-65]) elif i == ')' and len(stack) >= 2: a = stack.pop() b = stack.pop() cc += a[0]*a[1]*b[0] stack.append([b[0],a[1]]) print(cc)