Code: https://www.codechef.com/viewsolution/25394118

For context: I used a cumulative/prefix sum array to quickly compute the number of '1’s between [i, j]. Then for every starting index, for every length of k*(k+1), I checked if the sum was valid.

I re-wrote the solution multiple times now, and I have also compared this solution to a naive solution that checked all N^2 substrings and nothing seems wrong. However, when I submit the solution I’m getting a runtime error (NZE).

However, I checked every index & memory allocation, so I’m totally stumped at this point. Anybody have any tips or notice anything obviously wrong?