a. Determine the Photo Position
Determine the Photo Position
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Description
You have taken the graduation picture of graduates. The picture could be regarded as a matrix A of , each element in A is 0 or 1, representing a blank background or a student, respectively.
However, teachers are too busy to take photos with students and only took a group photo themselves. The photo could be regarded as a matrix B of where each element is 2 representing a teacher.
As a master of photoshop, your job is to put photo B into photo A with the following constraints:
- you are not allowed to split, rotate or scale the picture, but only translation.
- each element in matrix B should overlap with an element in A completely, and each teacher should overlap with a blank background, not shelter from a student.
Please calculate the possible ways that you can put photo B into photo A.
Format
Input
The first line contains two integers indicating the size of photos A and B.
In the next lines,each line contains characters of '0' or '1',representing the matrix A.
The last line contains characters of '2', representing matrix B.
Output
Output one integer in a line, indicating the answer.
Samples
5 3
00000
01110
01110
01110
00000
222
6
3 2
101
010
101
22
0
3 1
101
010
101
2
4
Limitation
1s, 1024KiB for each test case.
第七届SWPU-ACM新生预选赛
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 103
- Start at
- 2022-9-19 14:00
- End at
- 2022-10-28 14:00
- Duration
- 936 hour(s)
- Host
- Partic.
- 58