Problem link — 20C - Dijkstra?
Solution with custom comparator (give MLE) — 142440675
Solution without comparator (Accepted) — 142444892
The logic of both the solutions are same (Dijkstra). Only the implementation is different. Why does using a custom comparator give MLE?
The comparator seems to be ok. The real issue is here:
int curd = temp.F;
. You forgot that the type should bell
, thus leading to overflow. What happened next, I do not know, but negative distances were definitely bad.I got it thanks.