UVa442
来源:互联网 发布:淘宝卖家信用贷款 编辑:程序博客网 时间:2024/05/22 01:47
#pragma warning(disable:4996)#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<vector>#include<algorithm>#include<iostream>#include<time.h>#include<set>#include<sstream>#include<functional>#include<cassert>#include<list>#include<iterator>#include<utility>#include <stdexcept>#include <sstream>#include <fstream>#include<ctype.h>#include<map>#include<stack>using namespace std;int length;struct{ int x, y;}word[50000];stack<int> s;void print(string str){ int sum = 0; int len = str.size(); if (len == 1) { cout << 0 << endl; return; } int k = 0; while (k < len) { k++; if (str[k - 1] != ')') { int a; if (str[k - 1] >= 'A'&&str[k - 1] <= 'Z') a = str[k - 1] - 'A'; else { a = -1; } s.push(a); } else { int tmp1, tmp2; tmp2 = s.top(); s.pop(); tmp1 = s.top(); s.pop(); s.pop(); if (word[tmp1].y != word[tmp2].x) { cout << "error" << endl; return; } sum = sum + word[tmp1].x*word[tmp1].y*word[tmp2].y; length++; word[length].x = word[tmp1].x; word[length].y = word[tmp2].y; s.push(length); } } cout << sum << endl; return;}int main(){ int n; cin >> n; for (int i = 0;i < n;i++) { length = n - 1; char temp; cin >> temp; cin >> word[temp - 'A'].x; cin >> word[temp - 'A'].y; } string str; while (cin >> str) { print(str); } return 0;}
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
- 2017最新顺口溜出炉(超级经典)!
- 一些常用的Bootstrap模板资源站
- leetcode--sort_colors
- 巧用android 控件—CheckBox + 状态选择器
- JAVA入门笔记3:循环结构语句
- UVa442
- iOS10 Xcode8真机测试 code signing is required for product type 'Application' in SDK 'iOS 10.0'
- 关于原生js的位置操作以及尺寸操作
- sql中with nocheck的作用
- __autoload,spl_autoload_register与自动加载
- 图片选择器selector
- UVA1203 Argus (优先队列priority_queue)
- 神经网络快速入手
- 我的work list: Done, Doing, Push Doing, To Do