ZOJ Problem Set - 2130
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').
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.
4 4 2 2 OXXO XOOX OXXO XXOO O. .X 4 4 3 3 XXXX XXXX XXXX XXXX ... .X. ...
Time is just a mirage. The history and future branch off infinitely at every slice of time. All possible or impossible-like histories and futures exist individually and intersect at the current time space which make all relative existence related to each other.
Author: CHEN, Shixi
Source: Online Contest of Fantastic Game