QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 256 MB 總分: 100 互動

#7833. 二進制字串

统计

呢題係互動題。 最多可以詢問 $18\,000$ 次。

評測方有一個秘密字串,啱啱由 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.