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

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

Автор ChickenInKitchen, история, 7 лет назад, По-английски

why my submission gives wrong output here while it works fine on my computer ? 31150639

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

»
7 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

I don't know the answer for that but you can try to debug using the Custom Test in CF. If it still doesn't help you maybe you should explain your solution.

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

    well its weird . for this problem we should output 3 numbers . then last 2 are fine the first is correct in my computer for both samples but in CF its a nonsense number

»
7 лет назад, # |
Rev. 3   Проголосовать: нравится +7 Проголосовать: не нравится

In the loop

for(int j = 1 ; j <= n ; j ++ ){
    sdp[i][j] = (sdp[i - 1][j] + dp[i][j]) % mod;
}

When i = 0, you are accessing sdp[i - 1][j] which is undefined behaviour, which explains the fact that your submission gives some garbage value

Hope this helps!

»
7 лет назад, # |
  Проголосовать: нравится -8 Проголосовать: не нравится