struct val{
int v0, v1;
};
class Solution {
public:
val dfs(TreeNode* node){
if (node == nullptr) return {0, 0};
auto l = dfs(node->left);
auto r = dfs(node->right);
int cur0 = max(l.v0, l.v1) + max(r.v0, r.v1);
int cur1 = node->val + l.v0 + r.v0;
return {cur0, cur1};
}
int rob(TreeNode* root) {
auto ans = dfs(root);
return max(ans.v0, ans.v1);
}
};