The perfect xor hackerearth

i have written the code to find articulation point. How to proceed further in this question?

Observe that the question asks you to maximize xor of two sums. However the two sums are related. If you know the sum of all the nodes in the dfs subtree of some node, the sum of other part is total sum - total sum of dfs subtree - value of sum considered as articulation point(Since the node considered as articulation point also disappears). There can be atmost n-2 valid nodes to consider as articulation point. So while doing dfs for articulation point operation also maintain sum of subtree. Then find the sum of its counterpart by above formula and find the maximum. Use height info to find which node is considered as root of subtree.