node merge(node a, node b) {
node res;
res.cx = a.cx + b.cx;
res.lx = a.lx + a.cy ? 0 : b.lx;
res.rx = b.rx + b.cy ? 0 : a.rx;
res.mx = max(max(a.mx, b.mx), a.rx + b.lx);
res.cy = a.cy + b.cy;
res.ly = a.ly + a.cx ? 0 : b.ly;
res.ry = b.ry + b.cx ? 0 : a.ry;
res.my = max(max(a.my, b.my), a.ry + b.ly);
return res;
}
node Merge(node a, node b) {
node res;
res.cx = a.cx + b.cx;
res.lx = a.cy ? a.lx : a.cx + b.lx;
res.rx = b.cy ? b.rx : b.cx + a.rx;
res.mx = max(max(a.mx, b.mx), a.rx + b.lx);
res.cy = a.cy + b.cy;
res.ly = a.cx ? a.ly : a.cy + b.ly;
res.ry = b.cx ? b.ry : b.cy + a.ry;
res.my = max(max(a.my, b.my), a.ry + b.ly);
return res;
}