QOJ.ac

QOJ

Time Limit: 10 s Memory Limit: 256 MB Total points: 100 Difficulty: [show]

#380. 子矩阵搜索

Statistics

给定一个 $10^6 \times 10^6$ 的零一矩阵。第 $i$ 行($1 \le i \le 10^6$)第 $j$ 列($1 \le j \le 10^6$)的数值由以下 Java 代码定义(这被称为 Jenkins one-at-a-time hash):

long where = i * 1000000L + j;
int hash = 0;
for (int k = 0; k < 5; ++k) {
    hash += (int) ((where >>> (8 * k)) & 255);
    hash += (hash << 10);
    hash ^= (hash >>> 6);
}
hash += (hash << 3);
hash ^= (hash >>> 11);
hash += (hash << 15);
return (hash >>> 27) & 1;

其中 >>> 运算符是“无符号右移”,“long”类型是 64 位整数,“int”类型是 32 位整数。注意,这个哈希函数是随意选取的,对于任何足够随机的定义数值的函数 $f(i, j)$,本题都是可解的。

然后,我们随机且均匀地选取两个数字 $a$ 和 $b$($1 \le a, b \le 10^6 - 10^3 + 1$),并写下行号在 $a$ 到 $a + 999$ 之间、列号在 $b$ 到 $b + 999$ 之间的 $1000 \times 1000$ 子矩阵。

给定该子矩阵,你能找到 $a$ 和 $b$ 吗?你不需要找到原始的 $a$ 和 $b$,任何能产生给定子矩阵的数对均可。

输入格式

输入文件包含 1000 行。每一行对应子矩阵的一行,包含 1000 个字符。

输出格式

输出两个用空格分隔的数字 $a$ 和 $b$。

样例

样例输入 1

0000100111
1110101010
1010010001
0001101110
1001100010
0111011100
1001010001
0110110110
1010010110
0001011011

样例输出 1

165731 269905

说明

注意,第一个测试用例比上面的样例大,它有 1000 行,每行 1000 个字符。你可以从 http://forest.acm.petrsu.ru/tests/submatrix.in 下载第一个测试用例。本题共有 20 个测试用例,每个测试用例均根据题目描述随机生成。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.