QOJ.ac

QOJ

时间限制: 2.0 s 内存限制: 256 MB 总分: 100 交互

#18174. 猜表格

统计

评测机生成了一个大小为 $n \times m$ 的由 0 和 1 组成的矩阵 $A$。你需要猜出这个矩阵。

为此,你最多可以发送 200 次询问。最后,你需要输出目标矩阵。

每次询问由一个大小为 $a \times b$ ($1 \le a \le n, 1 \le b \le m$) 的矩阵 $B$ 描述,该矩阵由 0、1 和问号(?)组成。如果矩阵 $A$ 包含一个与给定模板 $B$ 相匹配的连续子矩阵,则询问的回答为 1。否则,回答为 0。

形式化地,当且仅当存在一组值 $(i, j)$ ($1 \le i \le n - a + 1, 1 \le j \le m - b + 1$),使得对于每个 $(x, y)$ ($1 \le x \le a, 1 \le y \le b$),满足 $B_{x,y}$ 是问号(?)或 $B_{x,y} = A_{i+x-1, j+y-1}$ 时,回答为 1。

此外,对询问矩阵 $B$ 还有一个限制:不能有任何一行或任何一列完全由问号组成。

请注意,本题是交互式问题,因此你在每次询问后以及最后给出答案后都需要清空输出缓冲区(flush)。在 C++ 中可以使用 fflush(stdout) 函数,在 Java 中可以使用 PrintWriter.flush()

输入格式

输入两个整数 $n$ 和 $m$ ($1 \le n, m \le 13$) —— 待猜测矩阵的大小。

输出格式

最后,你应该在第一行输出一个字符串 "Answer:"(不含引号)。之后输出 $n$ 行,每行包含 $m$ 个字符 "0" 或 "1" —— 即你猜出的矩阵。不要忘记在此之后清空输出缓冲区。

交互

在每次询问的第一行,输出一个字符串 "Query:"(不含引号)以及两个整数 $a, b$ ($1 \le a \le n, 1 \le b \le m$) —— 子矩阵的大小。之后输出 $a$ 行,每行包含 $b$ 个字符 "0"、"1" 或 "?"。不要忘记在此之后清空输出缓冲区。

每次询问后,你将获得一个回答 —— 单独的一行,如果目标矩阵包含给定的子矩阵,则为数字 1,否则为 0。

样例

输入样例 1

2 3
1
1
1
0

输出样例 1

Query: 2 1
0
0
Query: 1 2
01
Query: 2 2
01
0?
Query: 2 3
101
??0
Answer:
101
001

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.