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

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

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

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

»
9 лет назад, скрыть # |
 
Проголосовать: нравится +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.

»
9 лет назад, скрыть # |
← 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!