当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2842:N-dimension Matching

题目描述
Let us consider an n-dimension matching problem of two matrices. Here the index number of each dimension of a matrix starts at 1. For two n-dimension matrixes S and T, if there is a position (p1, p2, p3, p4, …,pn) which satisfies that each element at the position (t1, t2, t3, t4, …,tn) in T is the same as the element at the position (p1 + t1 - 1, p2 + t2 - 1, p3 + t3 - 1, p4 + t4 - 1, …,pn + tn - 1) in S, we call it’s a matching position. So the n-dimension problem is to compute the matching position for given S and T. You can assume that the traditional string matching problem is the 1-dimension version of this problem, and the normal matrix matching problem is the 2-dimension version.
输入解释
The first line contains the positive number n, which is not larger than 10.
The second line contains n positive numbers a1, a2, a3, ...,an, representing the range of each dimension of matrix S.
The third line contains n positive numbers b1, b2, b3, ...,bn, representing the range of dimensions of matrix T.
The fourth line gives the elements in S.
The fifth line gives the elements in T.

To give out an n-dimension matrix with size c1 * c2 * c3 * ... * cn in a line, we will give the element at the position (d1, d2, d3, …,dn) in the matrix as the (c2 * c3 * ... * cn * (d1 – 1) + c3 * c4 * ... * cn * (d2 – 1) + ... + cn * (dn - 1 – 1) + dn)–th element in the line.

We guarantee that bi <= ai, elements in S and T are all positive integers that are not larger 100, and the number of the elements in S and T are both not larger than 500000.
输出解释
You should output n numbers in a line, p1, p2, p3, …,pn, representing the matching position. Please print the lexically smallest one if there are many. We guarantee that there is at least one matching position.
输入样例
2
4 4
2 2
3 2 1 1 2 2 2 1 1 2 2 2 1 1 2 2
2 2 2 2
输出样例
2 2
来自北京大学POJ的附加信息
Case time limit(单组数据时间限制) 5000MS

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2842

最后修改于 2020-10-29T06:45:36+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
10000 131072