I am not getting how to approach this problem

In the prefix sum part where we find the sum dp[x][y] how
to find dp[x][y] and all the four rectangles?

int op1=dp[i][j];

    int op2=dp[i][n-1]-dp[i][j];

    int op3=dp[n-1][j]-dp[i][j];

    int op4=dp[n-1][n-1]-(op1+op2+op3);