QOJ.ac

QOJ

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

#18949. 01 数列を当てる

الإحصائيات

これはインタラクティブな問題です。

正の整数 $n$ が与えられると、ジャッジは未知の長さ $n$ の 01 数列 $a_1,a_2,\dots,a_n$ を生成します。ジャッジに最大 $17$ 回質問し、この 01 数列に含まれる 1 の個数、すなわち $\sum\limits_{i=1}^n a_i$ を求めてください。少なくとも 1 個の 1 が含まれることが保証されます。

各質問では、いくつかの位置 $i_1,i_2,\dots,i_k$ を選べます。$I=\{i_1,i_2,\dots,i_k\}$ とすると、ジャッジは $(\sum\limits_{j\in I} a_j) \cdot (\sum\limits_{j\notin I} a_j)$ の値を返します。

入力

最初の行には、この 01 数列の長さを表す正の整数 $n$ $(1\le n\le 10^5)$ が与えられます。

インタラクション

質問するには、次の形式で 1 行出力してください(引用符は含めません):

? k i_1 i_2 ... i_k $(1\le k\le n,1\le i_1< i_2< \dots< i_k\le n)$。

答えを出力するには、次の形式で 1 行出力してください(引用符は含めません):

! s、ここで $s=\sum\limits_{i=1}^n a_i$ です。

答えの出力自体は質問回数に含まれません。

インタラクタは非適応型です。つまり、答えは参加者が質問する前にすでに決まっており、参加者の質問に依存しません。

各質問を出力した後は、改行を出力し、出力バッファをフラッシュすることを忘れないでください。

バッファをフラッシュするには、次の文を使えます:

  • C/C++:fflush(stdout)
  • C++:std::cout << std::flush
  • Java:System.out.flush()
  • Python:sys.stdout.flush()

入出力例

入力 1

3

2

出力 1

? 2 1 3

! 3

入力 2

3

0

0

出力 2

? 1 1

? 1 2

! 1

注記

最初の入出力例の隠された数列は $[1,1,1]$、2 番目の入出力例の隠された数列は $[0,1,0]$ です。

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.