HG_90's blog

By HG_90, history, 4 years ago, In English

https://codeforces.net/contest/1364/submission/85603351

pls tell me why the above code shows runtime error on test case 6.

Someone pls correct this code

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

| Write comment?
»
4 years ago, # |
  Vote: I like it +10 Vote: I do not like it

You could assert that the set is not empty here auto it = s_minus_sq.begin(); before dereferencing it.

  • »
    »
    4 years ago, # ^ |
    Rev. 2   Vote: I like it +5 Vote: I do not like it

    Yeah, that's working thanks!

    But I think that the condition never arrives at which s_minus_sq.size() is 0 and control is at else if . That's why I haven't checked that condition.

    Can you tell me what lead you to that?

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

      The Checker Diagnostics looks like access to "bad" memory, and I did not see any other line of suspicious code.