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
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.