凑_友希那 @ 2018-07-23 16:21:26
三目运算符要打括号
inline void pushUp(Node *o) {
int t = 0;
if (o->child[0]) {
t += o->child[0]->val;
}
if (o->child[1]) {
t += o->child[1]->val;
}
o->val = t;
o->leftMaxSum = std::max((o->child[0] ? o->child[0]->leftMaxSum : 0), (o->child[0] ? o->child[0]->val : 0) + (o->child[1] ? o->child[1]->leftMaxSum : 0));
o->rightMaxSum = std::max((o->child[1] ? o->child[1]->rightMaxSum : 0), (o->child[1] ? o->child[1]->val : 0) + (o->child[0] ? o->child[0]->rightMaxSum : 0));
o->ans = std::max(std::max((o->child[0] ? o->child[0]->ans : 0), (o->child[1] ? o->child[1]->ans : 0)), (o->child[0] ? o->child[0]->rightMaxSum : 0) + (o->child[1] ? o->child[1]->leftMaxSum : 0));
return;
}
加法优先级更高
by 凑_友希那 @ 2018-07-23 16:21:54
好像乱了一点