QOJ.ac

QOJ

Límite de tiempo: 0.5 s Límite de memoria: 512 MB Puntuación total: 100

#12392. 印章

Estadísticas

Bytie 今天在他的邮件中发现了一份奇怪的文件。这是一份通知,称他在叔叔 Byteasar 去世后继承了一大笔钱。这份文件上有多个 Byteotia 王国印章的印记。不过为了保险起见,Bytie 想确认一下这是否是一场骗局。为此,他想确定这些印记是否是合法的印章印记。

Bytie 非常清楚 Byteotia 王国印章的样子。然而,他收到的文件上墨迹太多,很难判断是一个过于勤奋的职员盖了多次印章,还是有人试图欺骗 Bytie。请编写一个程序,根据文件上的印记和 Byteotia 王国印章的矩阵,判断文件上的印记是否合法。

Byteotia 王国印章具有复杂的安全措施,防止以下所有情况发生:(1) 旋转印章印记,(2) 制作出印章的一部分未出现在文件上的印记,以及 (3) 在文件的任何一点上盖上超过一个印章的印记。

输入格式

标准输入的第一行包含一个整数 $q$ ($1 \le q \le 10$),表示数据组数。接下来的行描述连续的数据集。

单个数据集描述的第一行包含四个整数 $n, m, a, b$ ($1 \le n, m, a, b \le 1000$),以空格分隔。

接下来的 $n$ 行描述了文件上的印记。每行包含 $m$ 个字符,每个字符要么是 .(点),要么是 x。点表示文件相应位置没有墨迹,而 x 表示有墨迹。

接下来描述了一个带有单个 Byteotia 王国印章印记的样本文件,格式与 Bytie 收到的文件相同,为 $a$ 行 $b$ 个字符,每个字符为 .x。你可以假设 Bytie 文件上的印记和合法的印章矩阵都包含墨迹。

在总分 44% 的测试中,满足 $n, m, a, b \le 150$。

输出格式

你的程序应向标准输出打印恰好 $q$ 行。第 $i$ 行应提供第 $i$ 个数据集的答案。

如果 Bytie 收到的文件可能是用合法印章盖印的,则该数据集的答案应为单词 TAK(波兰语中的“是”)。反之,如果文件是伪造的,则答案应为单词 NIE(波兰语中的“否”)。

样例

输入 1

2
3 4 4 2
xx..
.xx.
xx..
x.
.x
x.
..
2 2 2 2
xx
xx
.x
x.

输出 1

TAK
NIE

说明

样例评分测试:

  • 1ocen:单个数据集:文件大小为 $2 \times 3$,完全被墨迹覆盖,印章矩阵大小为 $1 \times 2$。答案:NIE
  • 2ocen:单个数据集:文件是 $8 \times 8$ 的棋盘格;印章矩阵是 $3 \times 3$ 的棋盘格。答案:NIE
  • 3ocen:$q = 10$,所有数据集满足以下条件:随机的 $20 \times 20$ 印章矩阵和 $1000 \times 1000$ 的文件,且仅有一个印章印记。所有答案:TAK

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.