Is codechef judge broken?

https://www.codechef.com/viewsolution/46501171
https://www.codechef.com/viewsolution/46501128

These submissions differ only in lines 44-45

SIGSEGV

    l--; r--;
    if (c1[l] + c2[r] - 1 >= (r - l + 1))

AC

    // l--; r--;
    if (c1[l - 1] + c2[r - 1] - 1 >= (r - l + 1))

Can anyone explain the reason behind this?

Looks very weird to me. Also, I couldn’t find any out of bounds that can cause any undefined behavior. Maybe @ssjgz knows.

1 Like

I also can’t find anything wrong. Since it was an external contest, I wouldn’t be surprised if the testcases were malformed.

Not a single Python AC, interestingly - Python will complain much more loudly if there are inputs missing.

Edit:

You could probably test this by submitting something that just reads in input and asserts if it finds something wrong (including eof, etc).

2 Likes