A11751 | Death Stars (medium)
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map of the solar system that contains the Death Star. However, this time the Empire has hidden the Death Star very well, and Heidi needs to find a place that appears on both maps in order to detect the Death Star.
The first map is an $N×M$ grid, each cell of which shows some type of cosmic object that is present in the corresponding quadrant of space. The second map is an $M×N$ grid. Heidi needs to align those two maps in such a way that they overlap over some $M×M$ section in which all cosmic objects are identical. Help Heidi by identifying where such an $M×M$ section lies within both maps.
The first map is an $N×M$ grid, each cell of which shows some type of cosmic object that is present in the corresponding quadrant of space. The second map is an $M×N$ grid. Heidi needs to align those two maps in such a way that they overlap over some $M×M$ section in which all cosmic objects are identical. Help Heidi by identifying where such an $M×M$ section lies within both maps.
输入格式
The first line of the input contains two space-separated integers $N$ and $M$ ( $1<=N<=2000$ , $1<=M<=200$ , $M<=N$ ). The next $N$ lines each contain $M$ lower-case Latin characters (a-z), denoting the first map. Different characters correspond to different cosmic object types. The next $M$ lines each contain $N$ characters, describing the second map in the same format.
输出格式
The only line of the output should contain two space-separated integers $i$ and $j$ , denoting that the section of size $M×M$ in the first map that starts at the $i$ -th row is equal to the section of the second map that starts at the $j$ -th column. Rows and columns are numbered starting from 1.
If there are several possible ways to align the maps, Heidi will be satisfied with any of those. It is guaranteed that a solution exists.
If there are several possible ways to align the maps, Heidi will be satisfied with any of those. It is guaranteed that a solution exists.
输入输出样例
输入 #1
10 5 somer andom noise mayth eforc ebewi thyou hctwo again noise somermayth andomeforc noiseebewi againthyou noisehctwo
输出 #1
4 6
输入 #2
2 XX OO XO OX
输出 #2
No
The 5-by-5 grid for the first test case looks like this:
```
<pre class="verbatim"><br></br>mayth<br></br>eforc<br></br>ebewi<br></br>thyou<br></br>hctwo<br></br>
```
```
<pre class="verbatim"><br></br>mayth<br></br>eforc<br></br>ebewi<br></br>thyou<br></br>hctwo<br></br>
```
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted