ab1414's blog

By ab1414, history, 3 years ago, In English

Hey guys these are two submissions with same code just a single difference in compare function , can anybody tell me why one is giving TLE and other not ??

TLE — https://codeforces.net/contest/1535/submission/118378801

AC — https://codeforces.net/contest/1535/submission/118474020

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

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

In the first case, it's undefined behaviour. If I were to compare, say, 2 and 6 with your comparator from first solution, I would get either 2 > 6 or 6 > 2, depending on the order I pass them. So, probably sorting function just falls into an infinite loop or something because of this.