Help needed in July circuit problem


There is no editorial of this problem and author’s solution and tags included are dijkstra, i am unable to comprehend the use of Dijkstra’s algo in this problem.
My approach do a simple bfs and if there is a path from a vertex to a node then the minimum value for the node will be min(dist[node],max(val[node],dist[x]) but i am getting wrong answer.

Please help. @l_returns @anon55659401

1 Like

Yes, I need help in the question too. Thanks for asking. IDK why HackerEarth does not provide editorials the way Codechef does. In the name of editorials you only find hard to understand codes of setter and tester.

It is dijkstra only! Make the value of the node as the weight of the edges. And then all you need to do is to find the shortest path from the given source.

At last don’t forget to take the shortest path value (obtained by dijkstra) with the node value of the destination (as in our algorithm this value is not considered).
Hope it help!

spam this guy https://codeforces.com/profile/Arpa to provide editorials . he provide editorials all the time . comment on this post too https://codeforces.com/blog/entry/68483