All submissions for this problem are available.
Your friend little Timo went to Bosonian school. The teacher gave her a homework to do. But, Timo is not that much intelligent for solving the homework. So, she asked you to solve her homework.
Your are given two rectangles A and B each of dimension NXM. There are NXM cells in each rectangle. The rows are numbered from 1 to N ,and the columns are from 1 to M. Each cell contains a number from 0 to 100. You are given some queries in the following form. Given the upper left corner (x1,y1) and lower right corner (x2,y2) of sub rectangles of A and B. That is, the two sub rectangles are present at the same position in both of the rectangles A and B. You have to count the number of numbers matched in the corresponding cells of the sub rectangles. That is,
A[i][j]=B[i][j], such that x1<=i<=x2, and y1<=j<=y2.
On the first line of every test case is given three space separated numbers N ,M and Q.
Then, 2*N lines follows. Each line contains M numbers. The first N line corresponds to the first rectangle, and from (N+1)th to 2*Nth line corresponds to the second rectangle.
Then, Q queries follow. Each query contains four integers x1,y1,x2,y2.
For each test case, output Q lines containing the number of corresponding cells matched in the sub rectangles.
- 1 ≤ T ≤ 20
- 1 ≤ N,M ≤ 1000
- 1 ≤ Q ≤ 1000
- 1 ≤ x1,x2 ≤ N
- 1 ≤ y1,y2 ≤ M
Input: 1 2 2 2 1 2 2 2 1 3 2 2 1 1 2 2 1 1 1 2 Output: 3 1
|Time Limit:||0.1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, GO|
Fetching successful submissions