For the question http://www.codechef.com/AUG13/problems/PRIMEDST , I read the editorial but just want to check if the approach i thought is correct or not:
Taking all vertices as root in each turn and doing BFS traversal calculating the distance to every other node. Since the root will be initialized to zero, if the distance of other node is a prime number, counting it will give us the probable cases.
This may not be a good solution complexity wise, but is the method correct??