题解 | #矩阵乘法计算量估算#
矩阵乘法计算量估算
https://www.nowcoder.com/practice/15e41630514445719a942e004edc0a5b
def calmul(a,b,c,d): return a*b*d num = int(input()) matrixs = [] for i in range(num): matrixs.append(input().split()) commands = input() order = [] res = 0 for command in commands: if command != ')': if command == '(': order.append(command) else: order.append(matrixs[ord(command)-ord('A')]) else: a = order.pop() b = order.pop() order.pop() order.append([b[0],a[1]]) res = res + calmul(int(b[0]),int(b[1]),int(a[0]),int(a[1])) print(res)