Dijkstra's Algorithm Codeforces

Problem Link -> https://codeforces.com/problemset/problem/20/C

please help me with this question i am unable to figure out what is wrong in my code as it is failing for 1 test case but working fine for some given cases.

Solution Link -> https://ide.codingblocks.com/s/470545

hello @Rajat02

the given graph can have self loop and multi edges , take care of it.

also for checking whetehr path exist or not.
u can simply check dist[n] if it remains INT_MAX even after dijkastra then that means no path

1 Like

ohh thanks a lot @aman212yadav but can you plz tell how to check for self loop or multi edge?? will i have to handle it separately??

check now->

1 Like

Thanks @aman212yadav for this solution :relaxed: it really helped a lot!! i was stuck in this question for the whole day.

plz share the link to feedback form :grin:

dont know why it is not showing, u can mark resolved from ur side and give rating accordingly

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like