lordsaitama's blog

By lordsaitama, history, 4 years ago, In English

I made a submission 83580212 to the problem 166A - Rank List and got a wrong answer to test case 15

I have encountered such errors while in contest that the code runs in my terminal but not in online judge

I am using the MinG terminal c++-14

Tried googling the problems but couldnot figure out the main issues. Can someone suggest the problem with code and extra flags i should use while compiling to avoid such blunders

  • Vote: I like it
  • 0
  • Vote: I do not like it

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

Your comparator function is written incorrectly. You need to remember that the comparator function must evaluate to false when two elements are equal. Yours doesn't work that way which leads to undefined behaviour and hence RTE.

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

.-._._-_.-_.-._-.. is correct. Just modify the custom comparator function on line 23 to return x.second < y.second; instead of return x.second <= y.second;. It would work.