This problem is in Contest(s) below:
Contest 1023:tree dp
Contest 1366:初中小朋友来玩Tree Dp
Contest 1104:Tree Dp从入门到精通
Contest 1361:状态压缩Dp及Tree Dp入门