Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя UzUmAk1_NaRuTo

Автор UzUmAk1_NaRuTo, история, 17 месяцев назад, По-английски

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.

  • Проголосовать: нравится
  • -26
  • Проголосовать: не нравится

»
17 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
17 месяцев назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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 месяцев назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    Thanks

  • »
    »
    17 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      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 месяцев назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

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

        • »
          »
          »
          »
          »
          17 месяцев назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          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 месяцев назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

There is some undefined behavior in your code

Hint