传送门:点击打开链接
题意:计算表达式,其中里面含有加减乘除括号
如果里面没有括号,那么使用栈简单维护一下即可
但是如果里面有括号了,或者有更复杂的运算符号,那么推荐使用表达式树来做
其实表达式树构造起来并没有想象中的那么麻烦,构造好之后直接分治算出答案即可
表达式树的核心思维就是找同优先级的最后一个运算符的位置,然后按照优先级递减顺序去考虑即可
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#define FIN freopen("input.txt","r",stdin)
#define FOUT freopen("output.txt","w+",stdout)
using namespace std;
typedef long long LL;
typedef pair<int, int>PII;
const int MX = 1e5 + 5;
char op[MX];
int lch[MX],