编程介的小学生 2017-08-16 15:33 采纳率: 20.5%
浏览 721
已采纳

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

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-08-28 15:52
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)