CF958A2.Death Stars (medium)
普及+/提高
通过率:0%
时间限制:2.50s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
星际日期为1983年,公主海蒂在探测死星方面已愈发得心应手。这一次,两名义军间谍再次向海蒂提供了两张标有死星可能位置的地图。由于上次她已清除了所有双重间谍,因此她确信这两张地图均准确无误,且确实描绘了包含死星的恒星系地图。然而,这一次帝国将死星隐藏得极为严密,海蒂必须找出一张同时出现在两张地图上的位置,方能定位死星。
第一张地图是一个 N×M 的网格,其中每个单元格表示对应空间象限中存在的一种宇宙天体。第二张地图是一个 M×N 的网格。海蒂需要以某种方式对齐这两张地图,使得它们在某个 M×M 的重叠区域内完全一致(即该区域内所有宇宙天体均相同)。请帮助海蒂确定这样的 M×M 区域在两张地图中的具体位置。
输入格式
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.
输入的第一行包含两个以空格分隔的整数 N 和 M(1 ≤ N ≤ 2000,1 ≤ M ≤ 200,M ≤ N)。接下来的 N 行,每行包含 M 个小写拉丁字母(a–z),表示第一张地图。不同的字符对应不同的宇宙物体类型。再接下来的 M 行,每行包含 N 个字符,以相同格式描述第二张地图。
输出格式
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.
输出仅有一行,包含两个用空格分隔的整数 i 和 j,表示第一张地图中起始于第 i 行、大小为 M×M 的子区域,与第二张地图中起始于第 j 列、大小为 M×M 的子区域完全相同。行号与列号均从 1 开始编号。
若存在多种对齐方式,Heidi 接受其中任意一种。题目保证解一定存在。
输入输出样例
输入#1
10 5 somer andom noise mayth eforc ebewi thyou hctwo again noise somermayth andomeforc noiseebewi againthyou noisehctwo
输出#1
4 6
说明/提示
The 5-by-5 grid for the first test case looks like this:
mayth
eforc
ebewi
thyou
hctwo
第一个测试用例的 5×5 网格如下所示:
mayth
eforc
ebewi
thyou
hctwo
输入解题思路,AI测评打分。不知道怎么写?