CF754E.Dasha and cyclic table
省选/NOI-
通过率:0%
时间限制:6.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Dasha is fond of challenging puzzles: Rubik's Cube 3 × 3 × 3, 4 × 4 × 4, 5 × 5 × 5 and so on. This time she has a cyclic table of size n × m, and each cell of the table contains a lowercase English letter. Each cell has coordinates (i, j) (0 ≤ i < n, 0 ≤ j < m). The table is cyclic means that to the right of cell (i, j) there is the cell
, and to the down there is the cell
.
Dasha has a pattern as well. A pattern is a non-cyclic table of size r × c. Each cell is either a lowercase English letter or a question mark. Each cell has coordinates (i, j) (0 ≤ i < r, 0 ≤ j < c).
The goal of the puzzle is to find all the appearance positions of the pattern in the cyclic table.
We say that the cell (i, j) of cyclic table is an appearance position, if for every pair (x, y) such that 0 ≤ x < r and 0 ≤ y < c one of the following conditions holds:
- There is a question mark in the cell (x, y) of the pattern, or
- The cell
of the cyclic table equals to the cell (x, y) of the pattern.
Dasha solved this puzzle in no time, as well as all the others she ever tried. Can you solve it?.
达莎喜欢挑战各种谜题:如3 × 3 × 3、4 × 4 × 4、5 × 5 × 5等魔方。这次她面对的是一个大小为 n×m 的循环表格,其中每个格子包含一个小写英文字母。每个格子具有坐标 (i,j)(满足 0≤i<n,0≤j<m)。所谓“循环”,是指:对于格子 (i,j),其右侧的格子为
,其正下方的格子为
。
达莎还有一个模板(pattern)。该模板是一个非循环的 r×c 表格,每个格子要么是一个小写英文字母,要么是一个问号 ?。每个格子具有坐标 (x,y)(满足 0≤x<r,0≤y<c)。
本谜题的目标是:找出该模板在循环表格中所有出现的位置。
我们称循环表格中的格子 (i,j) 是一个出现位置,当且仅当对所有满足 0≤x<r 且 0≤y<c 的坐标对 (x,y),以下两个条件之一成立:
- 模板中格子 (x,y) 的内容为问号
?;或者 - 循环表格中格子
的内容等于模板中格子 (x,y) 的内容。
达莎瞬间就解出了这道谜题,就像她解过的所有其他题目一样。你也能解出来吗?
输入格式
The first line contains two integers n and m (1 ≤ n, m ≤ 400) — the cyclic table sizes.
Each of the next n lines contains a string of m lowercase English characters — the description of the cyclic table.
The next line contains two integers r and c (1 ≤ r, c ≤ 400) — the sizes of the pattern.
Each of the next r lines contains a string of c lowercase English letter and/or characters '?' — the description of the pattern.
第一行包含两个整数 n 和 m(1≤n,m≤400)——循环表格的尺寸。
接下来的 n 行,每行包含一个长度为 m 的字符串,由小写英文字母组成——表示该循环表格的描述。
下一行包含两个整数 r 和 c(1≤r,c≤400)——模式的尺寸。
接下来的 r 行,每行包含一个长度为 c 的字符串,由小写英文字母和/或字符 ? 组成——表示该模式的描述。
输出格式
Print n lines. Each of the n lines should contain m characters. Each of the characters should equal '0' or '1'.
The j-th character of the i-th (0-indexed) line should be equal to '1', in case the cell (i, j) is an appearance position, otherwise it should be equal to '0'.
输出 n 行。每行应包含 m 个字符,每个字符为 '0' 或 '1'。
第 i 行(下标从 0 开始)的第 j 个字符应为 '1',当且仅当单元格 (i, j) 是一个出现位置;否则该字符应为 '0'。
输入输出样例
输入#1
5 7 qcezchs hhedywq wikywqy qckrqzt bqexcxz 3 2 ?? yw ?q
输出#1
0000100 0001001 0000000 0000000 0000000
输入#2
10 10 fwtoayylhw yyaryyjawr ywrdzwhscy hnsyyxiphn bnjwzyyjvo kkjgseenwn gvmiflpcsy lxvkwrobwu wyybbcocyy yysijsvqry 2 2 ?? yy
输出#2
1000100000 0000000001 0001000000 0000010000 0000000000 0000000000 0000000000 0100000010 1000000001 0000010000
输入#3
8 6 ibrgxl xqdcsg okbcgi tvpetc xgxxig igghzo lmlaza gpswzv 1 4 gx??
输出#3
000100 000001 000000 000000 010001 000000 000000 000000
输入解题思路,AI测评打分。不知道怎么写?