tusm851's blog

By tusm851, history, 5 weeks ago, In English,

I was solving the problems under Edu section when I found that for this problem under Suffix Array lectures, my solution works fine for the second test case on VS Code.

But the same code gives runtime error on CF. I am also unable to decipher the diagnostic comment which came attached with my submission, On further inspection I found that for different versions of gcc compilers, my solution gave runtime error on different test cases.

I am completely perplexed and would be grateful if someone sheds some light on this behavior.

UPD1 : Attaching the error comment screenshot and removing link to my submission.

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

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by tusm851 (previous revision, new revision, compare).

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by tusm851 (previous revision, new revision, compare).

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by tusm851 (previous revision, new revision, compare).

»
5 weeks ago, # |
  Vote: I like it +1 Vote: I do not like it

We cannot see your submission because it is from Edu section -- submissions there are not public, so apparently you should not share your code. Copy the diagnostic comment instead, maybe it will be enough to tell what's the problem.

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Oh sorry, I did not know that.

    I have removed the link to submission now. But won't you have to look at my code to figure out what's wrong? Also I have updated the blog where you can see the diagnostic comment.

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      It seems like the problem occurs in line 256. Maybe you can just paste a part of your code.

      • »
        »
        »
        »
        5 weeks ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        Please go through this. I have commented the line 256 so that you may find it easily. Also, I have added comments for better readability.

        Spoiler

        Many thanks for your concern in the problem!

        • »
          »
          »
          »
          »
          5 weeks ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          All I can say is v2[i].ff happens to exceed the bounds of v1. For example, in the test

          a
          1
          a
          

          v2[i].ff = 97 but v1 has size 1.

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

            Yes, my code does not work on this test case. Thanks, for showing me this. My solution got accepted after making the necessary changes.

            But, it still baffles me how the same code passes Test case 2 of the problem for C++17 and gets stuck at the same test case for C++11. It would be of immense help if you could explain me this phenomenon.

            • »
              »
              »
              »
              »
              »
              »
              5 weeks ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              My guess is that it is optimization differences. Optimizations should be more advanced in C++17, so if the compiler sees that some part of the code does not influence the result (let's say, after some point whatever you do with eome variables, it is bot logically linked to the variables, used later, e.g. ones printed as answer), it just skips it entirely. But it is really hard to say for sure, at least for me.

              • »
                »
                »
                »
                »
                »
                »
                »
                5 weeks ago, # ^ |
                  Vote: I like it 0 Vote: I do not like it

                After seeing the results I think I should switch to C++17 as my default language.

                Nevertheless, thanks for your replies and your help.

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by tusm851 (previous revision, new revision, compare).