im_115's blog

By im_115, history, 3 years ago, In English

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?

  • Vote: I like it
  • -9
  • Vote: I do not like it

»
3 years ago, # |
  Vote: I like it +24 Vote: I do not like it

The comparator seems to be ok. The real issue is here: int curd = temp.F;. You forgot that the type should be ll, thus leading to overflow. What happened next, I do not know, but negative distances were definitely bad.