QOJ.ac

QOJ

実行時間制限: 2.0 s メモリ制限: 256 MB 満点: 100 インタラクティブ

#12556. 跳跃

統計

考虑一个定义如下的玩具交互式问题 ONEMAX。已知一个整数 $n$ 和一个长度为 $n$ 的隐藏位串 $S$。你唯一能做的就是向系统提交一个长度为 $n$ 的位串 $Q$,系统将返回 $\text{ONEMAX}(Q)$ 的值,即 $Q$ 和 $S$ 在对应位置上相同的位数。ONEMAX 问题的名称源于这样一个事实:当 $S = 111 \dots 11$ 时,该问题更容易解释,此时问题转化为求位串中 1 的个数(One)的最大化(Max)。

当 $n$ 为偶数时,存在一个类似(但更难)的交互式问题,称为 JUMP。描述 JUMP 最简单的方法是使用 ONEMAX:

$$\text{JUMP}(Q) = \begin{cases} \text{ONEMAX}(Q) & \text{如果 } \text{ONEMAX}(Q) = n \text{ 或 } \text{ONEMAX}(Q) = n/2; \\ 0 & \text{其他情况。} \end{cases}$$

基本上,你在 JUMP 中能看到的唯一非零 ONEMAX 值是 $n$(这意味着你已经找到了隐藏字符串 $S$)和 $n/2$。

给定一个偶数 $n$(问题规模),你必须通过进行交互式 JUMP 查询来解决隐藏字符串 $S$ 的 JUMP 问题。你的任务是最终进行一次查询 $Q$,使得 $Q = S$。

交互

首先,测试系统会告知位串的长度 $n$。然后,你的程序进行查询,系统根据 JUMP 的定义回答这些查询。当程序询问的查询 $Q$ 满足 $Q = S$ 时,系统会回答 $n$ 并终止程序,因此如果你的程序在读取到答案 $n$ 后尝试继续读取或写入任何内容,程序将会失败。

查询次数限制为 $n + 500$。如果你的程序进行了第 $n + 501$ 次查询,你将收到“Wrong Answer”的结果。如果你的程序过早终止,也会收到此结果。

如果你的查询包含非法字符(非 0 或 1),或者长度错误(不等于 $n$),系统将终止测试,你将收到“Presentation Error”的结果。

你将因常见的违规行为收到“Time Limit Exceeded”或其他错误结果。

最后,如果一切正常(例如,你的程序在每个测试点上都找到了隐藏字符串),你将收到“Accepted”结果,此时你已解决了该问题。

输入格式

输入流的第一行包含一个偶数 $n$ ($2 \le n \le 1000$)。接下来的输入流行包含对应查询的答案。每个答案都是一个整数——即 $0$、$n/2$ 或 $n$。每个答案占一行。

输出格式

进行查询时,打印一行包含长度为 $n$ 的字符串,该字符串仅由字符 0 和 1 组成。打印查询后,请务必换行并刷新输出流。

样例

输入 1

2
1
0
1
2

输出 1

01
11
10
00

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.