### justHusam's blog

By justHusam, history, 4 years ago, ,

Today I was solving this problem 632C - The Smallest String Concatenation.

The judge's response for this code 18114819 was Runtime error on test 8.

Then I changed only the last line in the sort comparison function (comp function) from (return true) to (return false) (code: 18114847), and the judge's response was Accepted.

Does anyone have an explanation for that?

Thank you.

• +1

 » 4 years ago, # |   +9 Your comparator returns 1 for comp(a, a) which is incorrect.
•  » » 4 years ago, # ^ |   +1 Thank you for the explanation.
 » 4 years ago, # |   -11 1800+ guy asking this... Well, I have an explanation in just four letters! SpoilerRTFM
•  » » 4 years ago, # ^ |   +43 Thank you for your high morals.
•  » » 4 years ago, # ^ |   +17 LOL!! You're participating for more than 5 years and still violet!!Why so harsh? It's one of trickier technical details.
•  » » » 4 years ago, # ^ |   -15 I'm violet because I'm not able to solve hard problems. Everyone has their limits in different areas and it can't be fixed. From the other side, everyone is able to read a language manual. When I use a function, I read its docs. And you? The topicstarter doesn't. He didn't even try to find it in Google or Stackoverflow.
•  » » » » 4 years ago, # ^ |   0 I will surprise you but ability of understanding manuals and efficient googling is also a skill one can be good or bad at it. For example, I am at most cyan at both :). Even if it is possible that I will be able to find an answer in Google I often choose to ask somebody, because a friend will probably understand me better than Google.
•  » » » 4 years ago, # ^ |   +13 Well. I have an explanation in just three letters! SpoilerPMS
 » 4 years ago, # |   +8 Becuase std::sort is using operator < as a parameter, it is incorrect to use function which returns true in case of equality. This might sometimes end up in an RE. Not sure when exactly, but in most cases it will.
•  » » 4 years ago, # ^ |   +6 Thank you for the explanation.