ChickenInKitchen's blog

By ChickenInKitchen, history, 7 years ago, In English

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

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

| Write comment?
»
7 years ago, # |
  Vote: I like it +1 Vote: I do not like it

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 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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 years ago, # |
Rev. 3   Vote: I like it +7 Vote: I do not like it

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!