-
Quote:
Originally Posted by
xuftugulus
Code:
WHILE(isConnected(1,0)) DO
BEGIN
P = minimumPath(1,0);
X += NUMBER_OF_EDGES(P);
REMOVE_PATH(G,P);
END
I'm fairly certain that you meant to say 1 there. Adding the number of edges in the path you found wouldn't make any sense (you only need to remove one of the edges in the path to break it).
Also your solution doesn't consider one of the trickiest parts of the problem:
"Your main advantage is the fact that you can collapse tunnels whenever you like, based on your observations as the spy moves through the tunnels."
Which basically means that your algorithm is only a small part of the solution. Like I said, its complicated.
This is why for the second input case your algorithm returns 3, when the solution is actually 2.