blunder-brain's blog

By blunder-brain, history, 5 months ago, In English

Latest Submission

I am getting runtime error on testcase 2 idk why somebody please help! The issue is related to an access violation, even though I have applied checks everywhere.

Issue Solved!

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

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

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

»
5 months ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it
if(index+2 < arr.size()){
        gcd[index] = __gcd(arr[index+1], arr[index+2]);
    }
    else{
        gcd[index] = INT_MAX;
    }

In else block gcd[index] minght be out of bounds

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

    New Submission

    Well it still says runtime error

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

      That's because arr is by one number bigger than gcd

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

        okay but how can I fix this problem?

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

          Try replacing arr.size() with gcd.size() in

          else if(index<arr.size() && index >= 0 ){
                  gcd[index] = INT_MAX;
              }
          

          I don't know I haven't read the task

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

          okay okay it is accepted now thanks for help!

          The error was that I was accessing index-1 in gcd array but I was applying checks for case where I was accessing in arr array. In corrected version I applied checks based on which array I was accessing.

          Thanks once again!

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

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

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

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

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

no sh*t bro added the tag mysterious runtime error lol XD