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

Автор rurixx, история, 4 года назад, По-русски

I was solving 1684D - Ловушки of recent contest and have faced with strange thing.

Pls look at two pairs of submissions. (There are very simple code)

  1. 157815234 — OK, 157815120 — Time limit

  2. 157814018 — OK, 157813947 — Run-time error

In both pairs codes' difference is the same: 'wrong' submission uses lambda function with operator >= instead of > in 'good' submission.

Can it be explained?

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

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

i suppose (i'm not sure of course), that sorting with operator >= is bad because comparator can swap equal elements infinitely (sounds a bit crazy, but seems like there are not other reasons for RE and TL)

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

if comparator returns true for (a, b) it should return false for (b, a). otherwise it's undefined behavior