Bugged system input?


#1

With this input: 3 10 20 30 1 0 0 1 1 1 1 1 0

How it comes that node 10 (in the passed graph) has 3 neighbors !?!?


#2

My guess is all nodes are added as first node’s children, to make sure all nodes are reachable.
Said otherwise, arbitrary graphs are turned into connected ones.

In my book, it makes thing more confusing and allows half-baked solutions to pass (which is bad, since we might overlook the unconnected case, as I did).


#3

Probably too late for OP but this is not bugged. The graph is undirected so when you say there is an edge from 20 to 10 then it also means that there is an edge between 10 to 20.
If (i,j) = 1 then tester takes (j,i) = 1 even if you give it as zero.