Easy task
Time Limit : 5 Second
Memory Limit : 128 MB
Submission: 360
Solved: 170
- Description
- This is an easy task , you are given a N*N square , write a program calculates the sum of a given sub-matrix.
- Input
- First line contains tow integer N and Q (N <= 250 , Q <= 100000 )
2..N+1 line : Each line contains N integer , denotes the kth line of the matrix
N+2..N+Q+1 line: each line contains four integer r0 c0 r1 c1 , describes a sub matrix. r0 c0 denotes the position(r0 row and c0 column) of upper left element of the sub-matrix in the square,and r1 c1 denotes the position of the lower right element.
- Output
- For each sub-matrix in the input data , print a line contains the sum of the sub-matrix.
- sample input
-
6 3 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 6 6 2 3 4 5
- sample output
-
1 180 45
- hint
- source
- Ghost