Why my code isn't working?

http://www.codepile.net/raw/okzonOJ7.cpp

hello @premang ,
image

u need to handle those cases separately where i=0 or j=0 or both zero.

but how ? but how ?but how ?but how ?but how ?but how ?but how ?

@premang
take 0 for values that are having i-1 or j-1 negative

check this -> https://ide.codingblocks.com/s/195017

I DONT UNDERSTAND WHATS THE NEED FOR WRITING
if (x1 == 0 && y1 == 0) {
p = 0;q = 0;r = 0;
} else if (x1 == 0) {
p = 0;
q = csum_arr[x2][y1 - 1];
r = 0;
} else if (y1 == 0) {
p = csum_arr[x1 - 1][y2];
q = 0;
r = 0;
} else {
p = csum_arr[x1 - 1][y2];
q = csum_arr[x2][y1 - 1];
r = arr[x1 - 1][y1 - 1];
}

@premang

consider an example
for i=0 and j!=0
image

the highlighted part will be invalid because i-1 will be -1 right?
so i m just replacing them with value zero.

in the code i m handling
these possibilities separtely
i!=0 and j!=0
i=0 and j!=0
i!=0 and j=0
i=0 and j=0