Given a undirected unweighted acyclic graph, the root is always one (1), given inital and final states for each node in graph, the state is binary (either 0 or 1) . Do the following operations and return nodes on which the operations has performed in sorted ascending order.
The first contains the integer N the number of vertexes.
Next contains edges between vertexes/nodes.
Last but one line contains inital states of N vertexes.
Last line contains final states of N vertex.
5
1 2
1 4
2 3
4 5
1 0 0 1 1
0 1 0 1 11 2 3 51's inital states is 1 and final state is 0 , flip one's and all its descendents which occur at odd level from one. Which are 3 and 5 (whose inital states are now 1 and 0 respectively).2's inital states is 0 and final state is 1 , flip two and all its descendents which occur at odd levels , i.e., no nodes.3's and 5's state.