Please read the new rule regarding the restriction on the use of AI tools. ×

UzUmAk1_NaRuTo's blog

By UzUmAk1_NaRuTo, history, 17 months ago, In English

Can someone help me, I am facing this(Title) runtime error while submitting my solution to the problem 1822F - Gardening Friends Link to my submission-[submission:206155993]. The solution is working on my VS Code and various online IDEs. Thanks.

  • Vote: I like it
  • -26
  • Vote: I do not like it

| Write comment?
»
17 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Clion says that in line: int x1 = G[s][ind]; you have s = 0, ind = -1.

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

I have run your code on custom invocation and I wanted to tell you where the error is. The error is in variable x2 (at line 179), it's value is like 2882432546906025180 if you run it on test case 2 and output x2 before saying dp[x2] (which will of course go out of bounds). When your own IDE is giving correct and CF is not then run on Custom Invocation to check where is the fault.

Just a suggestion that, kindly write your codes such that they are more readable and understandable, look at other people codes (after getting accepted or lot of hard work) to learn how to improve implementation. I have got it accepted just now, you can see my code, and you can ask me if you don't understand something.

My Code : 206168140.

  • »
    »
    17 months ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    Thanks

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

    how did u find the specific error? how do we correctly use custom invocation? All i do is cout my variables and check for out of bounds conditions. Is there any better way to debug using custom invocation?

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

      I actually did not know what was going in his code, So I just used kind of binary search and wrote

      cout << "HERE" << endl;
      

      at different lines, which told me that the part till here does not have an error. And found the line which had the error.

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

        I was just curious as to why it happens that on some IDE it works and on some it doesn't.

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

          On the IDE it works, I think that IDE might be using some optimizations/smartness, like Sometimes I don't (when using #include <iostream>) include vector but the IDE is smart and does not give me error that you didn't include vector... but this is not standard C++. You have to include vector otherwise you will get compilation error on Codeforces. I think both of the cases are same, but not sure.

»
17 months ago, # |
  Vote: I like it +8 Vote: I do not like it

There is some undefined behavior in your code

Hint