Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

Approach for PRIMEDST

$
0
0

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??


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>