uva442
来源:互联网 发布:php is empty 编辑:程序博客网 时间:2024/05/16 19:46
#include <fstream>#include <iostream>#include <string>#include <cstring>#include <complex>#include <math.h>#include <set>#include <vector>#include <map>#include <queue>#include <stdio.h>#include <stack>#include <algorithm>#include <list>#include <ctime>#include <memory.h>#include <ctime>#include <assert.h>#define rep(i,a,n) for (int i=a;i<n;i++)#define per(i,a,n) for (int i=n-1;i>=a;i--)#define pb push_back#define mp make_pair#define all(x) (x).begin(),(x).end()#define fi first#define se second#define eps 1e-8#define M_PI 3.141592653589793typedef long long ll;const ll mod=1000000007;const int inf=0x7fffffff;ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}using namespace std;struct M{ int x,y;}a[150];stack<M>sta;int main(){ ios::sync_with_stdio(false); int n; cin>>n; for(int i=0;i<n;i++){ char c; cin>>c; int d=c-'A'; cin>>a[d].x>>a[d].y; } string s; while(cin>>s){ int flag=0,res=0; while(!sta.empty()) sta.pop(); if(s[0]!='(') cout<<0<<endl; else{ for(int i=0;i<s.size();i++){ if(isalpha(s[i])) sta.push(a[s[i]-'A']); else if(s[i]==')'){ M t2=sta.top();sta.pop(); M t1=sta.top();sta.pop(); //cout<<t1.x<<t1.y<<t2.x<<t2.y<<endl; if(t1.y!=t2.x){ flag=1; break; } res+=t1.x*t1.y*t2.y; M t={t1.x,t2.y}; sta.push(t); } } if(flag) cout<<"error"<<endl; else cout<<res<<endl; } }}
0 0
- UVA442
- uva442
- UVA442
- UVa442
- uva442
- uva442
- uva442
- UVa442
- UVa442
- UVa442
- UVa442
- uva442 栈
- UVA442栈
- uva442 Matrix Chain Multiplication
- uva442 Matrix Chain Multiplication
- uva442-矩阵链乘
- uva442-Matrix Chain Multiplication
- UVA442 Matrix Chain Multiplication
- 题目1523:从上往下打印二叉树
- Redis学习记录之命令GEO(十五)
- 做一个码农
- spring aop 1
- 用Fragment解决屏幕旋转(状态发生变化)状态不能保持的问题
- uva442
- 即时通信XMPP协议实现原理介绍
- 使用XML的五种场合
- 百度地图Android SDK坐标转换方法
- 网络游戏同步法则
- struts2 下 ajax 请求被执行两次
- android:layout_weight的真实含义
- win7 + VS2010配置opencv、boost、QT、QT-addin、CGAL
- 中国互联网年度趋势报告