Time Limit : 20 Second
Memory Limit : 128 MB
Submission: 66
Solved: 19
Description
There are two Integer Rectangles, a bigger one and a smaller one. Your work is to tell me how many sub-rectangles in the bigger rectangle that equals the smaller rectangle.
Input
There are multiply test cases. For each test case, the format of that case is below:
In the first Line, there are four Integers: R,C,r and c(0<R,C<=2000,0<r,c<=1000,r<=R and c<=C).
The next R lines described the bigger rectangle, for each line there are C Integers.
The next r lines described the smaller rectangle, for each line there are c Integers.
All the Integers in the Rectangles are non-negtive and smaller than 10000.
Output
For each test case, output the answer for a line.
sample input
4 4 2 2
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1
1 1
4 4 3 2
1 1 1 1
1 1 1 1
1 2 1 1
1 1 1 1
1 1
1 1
1 1
sample output
9
2
hint
source
Wang Liangjing
Submit