gastonvale99's blog

By gastonvale99, history, 3 years ago, In English

Hi everyone!. Im stuck with a bug in this problem. I tried to debug it, the code gets a runtime error in the cin>>buff line, when trying to get the last number (n=1999, and runtime error at i=1998). I will be glad if you can help me. Thanks!!!

My Submission: 123961933

Problem: 1546C — AquaMoon and Strange Sort

  • Vote: I like it
  • +8
  • Vote: I do not like it

»
3 years ago, # |
  Vote: I like it +11 Vote: I do not like it

The comparison function of sort must be a strict order : It must return false when x = y. Replacing > with >= gives AC.

  • »
    »
    3 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    WoW thanks mate!!. I still dont understand well. I put couts in the code to debug it, and i was sure that it stopped in the cin. That was incorrect? or was de comp function messing the things?. Other question, the sort function, swap items when the comp return true? or when return false? Im a bit confused with that. Have a nice day!

    • »
      »
      »
      3 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Remembers me of this. From what i know the reason for that going terribly wrong is that the way they check if a and b are equal is by seeing if cmp(a,b) and cmp(b,a) both return false.