编程介的小学生 2017-03-12 09:40 采纳率: 20.5%
浏览 747
已采纳

5 Spots

5 Spots is one of my favourite games of Fantasy Games series. In the game you should find out the 5 spots hidden in each picture within a limited time. And if you make a mistake you will lose some time available. The game ends when you find out all the five spots or the available time is used up. There is so many pictures in the game that it is almost impossible to remember the locations of the spots on all the pictures.

Let's consider a simplified game mode. You are given a rectangular monochrome picture in which several spots are hidden. The shapes of every spots are the same. A shape of spot is also a rectangular monochrome picture but some area may be transparent. Your task is to find out all the hidden spots and answer how many spots are hidden in the picture.

Input

Input contains multiple test cases. Each test case starts with four positive numbers H, W, h, w (1 <= h <= H <= 60, 1 <= w <= W <= 60), which is the height and width of the picture and the height and width of the shape of spots respectively. Then the following H lines show the figure of the picture, each line has W characters. The character may be 'O' or 'X' which specifies the color. Then the following h lines show the figure of the shape of the spots, each line has w characters. The character may be 'O', 'X' or '.' which specifies the color or a transparent area (which can match either color 'O' or 'X').

Output

There is one line for each test case, which is the number of spots you find out on the picture. If you find out no spots hidden in the picture, just output 0.

Sample Input

4 4 2 2
OXXO
XOOX
OXXO
XXOO
O.
.X
4 4 3 3
XXXX
XXXX
XXXX
XXXX
...
.X.
...
Sample Output

2
4

  • 写回答

2条回答 默认 最新

查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Oracle触发器记录修改前后的字段值
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器