#C6651. Submatrix Sum

    ID: 50435 Type: Default 1000ms 256MiB

Submatrix Sum

Submatrix Sum

You are given an integer matrix of size \( m \times n \) along with four integers \( r1, c1, r2, c2 \) that define the top-left and bottom-right corners of a submatrix. Your task is to compute the sum of all elements within this submatrix.

The submatrix is defined as all elements \( matrix[i][j] \) such that \( r1 \le i \le r2 \) and \( c1 \le j \le c2 \).

Input Format: The matrix and indices are provided via standard input.

Example:

Input:
3 3
1 2 3
4 5 6
7 8 9
0 0 1 1

Output:
12

Note: Use efficient looping constructs to compute the sum.

inputFormat

The first line contains two integers \( m \) and \( n \) representing the number of rows and columns of the matrix, respectively.

The following \( m \) lines each contain \( n \) space-separated integers representing the matrix elements.

The last line contains four space-separated integers \( r1, c1, r2, c2 \), which denote the top-left and bottom-right indices (0-indexed) of the submatrix.

outputFormat

Output a single integer which is the sum of the submatrix defined by the given indices.

## sample
3 3
1 2 3
4 5 6
7 8 9
0 0 1 1
12