Блог пользователя ab1414

Автор ab1414, история, 3 года назад, По-английски

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.com/contest/1535/submission/118378801

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

  • Проголосовать: нравится
  • -19
  • Проголосовать: не нравится

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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.