QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 256 MB مجموع النقاط: 100 تفاعلية

#7833. 二进制字符串

الإحصائيات

这是一个交互式问题。

评测系统拥有一个由恰好 1000 个二进制数字组成的秘密字符串。对于本题的每个测试点,该字符串在预先设定后保持不变。你需要通过询问来找出这个字符串。

在每次询问中,你选择一个区间 $[a, b]$ ($1 \le a \le b \le 1000$) 进行询问。随后,评测系统会抛掷一枚硬币,并以 50% 的概率返回以下两个值之一:

  1. 区间 $[a, b]$ 中 1 的个数;
  2. 一个从 0 到 $b - a + 1$ 之间且不等于该区间内 1 的个数的值,该值是均匀随机选取的。

你不允许重复使用相同的询问。本题中使用的所有随机值都是均匀且独立的。

交互格式

参赛程序必须通过打印以下格式的命令与评测系统进行交互:

  • ? a b”。查询区间 $[a, b]$。为了回答此查询,评测系统将输出一个整数,该整数有 50% 的概率是区间 $[a, b]$ 中 1 的个数,或者是一个从 0 到 $b - a + 1$ 之间且不等于该个数的随机值。
  • ! ans”。问题的答案,其中 ans 是一个长度为 1000 的由 0 和 1 组成的字符串。执行此命令后,参赛程序应立即终止。

样例

输入格式 1

2
3
3
1
3

输出格式 1

? 1 3
? 1 5
? 3 5
? 2 3
? 2 5
! 01101

说明

上述样例仅用于演示格式。在该样例中,字符串的长度为 5。在真实的第一个测试点以及所有其他测试点中,待猜测的字符串长度均为 1000。

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.