Company: Optum_1oct
Difficulty: medium
Break One Node to Split the Network Alice and Bob are playing a game. They are given a connected undirected graph containing n nodes and m edges. Each node has a sweetness value, given by the array w . Alice moves first: 1. In the first move, Alice breaks a node. Every edge connected to this node vanishes, and the broken node itself belongs to nobody. 2. In the second move, Bob picks any one connected component of the remaining graph. 3. In the third move, Alice picks any one of the remaining connected components, if there is any. The game then ends. Both players want to maximize their own score, which is the total sweetness they collect. They are not trying to minimize each other's scores. Task Determine the maximum score of Alice and the resulting score of Bob, assuming both play optimally. Notes 1-based indexing is followed. A connected component is a maximal set of nodes in which any two nodes are connected by one or more paths. The sweetness value of a connected component is the s