#include<stdio.h> #include<string.h> int compute(int headx,int heady,int subx,int suby,int x[],int y[]) { int n; n=subx*heady*suby; return n; } int main(void) { int num; scanf("%d",&num); int x[16]={0}; int y[16]={0}; for(int i=0;i<num;i++) { scanf("%d",&x[i]); scanf("%d",&y[i]); } char str[100]={0}; scanf("%s",&str); int x_stack[100]={0}; int y_stack[100]={0}; char symbolstack[100]={0}; int dx_size=0; int dy_size=0; int s_size=0; int len=strlen(str); int sum=0; for(int i=0;i<len;i++) { if(str[i]=='(') { symbolstack[s_size++]=str[i]; } if(str[i]>='A'&&str[i]<='Z') { int ii=str[i]-'A'; x_stack[dx_size++]=x[ii]; y_stack[dy_size++]=y[ii]; } if(str[i]==')') { sum+=compute(x_stack[dx_size-1],y_stack[dy_size-1],x_stack[dx_size-2],y_stack[dy_size-2],x,y); int x1=x_stack[dx_size-2]; int y1=y_stack[dy_size-1]; dx_size--;//数据栈顶取出 dx_size--;//数据栈倒数第二个取出 dy_size--; dy_size--; x_stack[dx_size++]=x1; y_stack[dy_size++]=y1; s_size--; } } printf("%d",sum); return 0; }