E - Bad Juice Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 425

問題文

この問題は インタラクティブな問題(あなたが作成したプログラムとジャッジプログラムが標準入出力を介して対話を行う形式の問題)です。

1 から N の番号がついた N 本のジュースがあります。 このうちちょうど 1 本が腐っていることが判明しました。 そのジュースを微量でも飲むと、翌日お腹を壊してしまいます。

高橋君は翌日までに腐ったジュースを特定しなければなりません。 高橋君はそのために必要な最小の数の友人を呼び、それぞれに N 本のジュースのうちの一部を振る舞うことにしました。 各友人には何本でもジュースを与えることができ、各ジュースは何人の友人にでも与えることができます。

呼ぶ友人の数とジュースの与え方を出力して、翌日に各友人がお腹を壊したかどうかの情報を受け取り、腐ったジュースの番号を出力してください。

制約

  • N は整数
  • 2 \leq N \leq 100

入出力

この問題はインタラクティブな問題(あなたが作成したプログラムとジャッジプログラムが標準入出力を介して対話を行う形式の問題)です。

対話を行う前にジャッジは、腐ったジュースの番号 X として 1 以上 N 以下の整数を秘密裏に選択します。 X の値はあなたには与えられません。また、対話の途中で X の値が制約および以前の出力に矛盾しない範囲で変わる場合があります。

まず、ジャッジから N が入力から与えられます。

N

あなたは呼ぶ友人の数 M を出力し改行してください。

M

さらに、あなたは次に述べる M 回の出力からなる手続きを行ってください。 i = 1, 2, \ldots, M について i 回目の出力では、 i 番目の友人に飲ませるジュースの本数 K_i および、それら K_i 本のジュースの番号を昇順に並べた列 A_{i, 1}, A_{i, 2}, \ldots, A_{i, K_i} を下記の形式で空白区切りで出力し、改行してください。

K_i A_{i, 1} A_{i, 2} \ldots A_{i, K_i}

その後ジャッジから、各友人が翌日にお腹を壊したかどうかの情報が、01 のみからなる長さ M の文字列 S として与えられます。

S

i = 1, 2, \ldots, M について、Si 文字目が 1 のとき、かつそのときに限り、i 番目の友人がお腹を壊したことを表します。

それに対し、あなたは腐ったジュースの番号 X' を出力し、改行してください。

X'

その後、直ちにプログラムを終了してください。

あなたが出力した MN 本のジュースから腐ったジュースを特定するために必要な最小の友人の数であり、かつ、あなたが出力した X' が腐ったジュースの番号 X と一致していれば、正解となります。

注意点

  • 出力を行うたびに、末尾に改行を入れて標準出力を flush してください。そうしなかった場合、ジャッジ結果が TLE となる可能性があります。
  • 対話の途中で不正な出力を行った、あるいはプログラムが途中で終了した場合のジャッジ結果は不定です。 特に、プログラムの実行中に実行時エラーが起こった場合に、ジャッジ結果が ではなく TLE になる可能性があることに注意してください。
  • X' を出力したらただちにプログラムを終了してください。そうしない場合、ジャッジ結果は不定です。
  • この問題のジャッジはアダプティブです。つまり、制約および以前の出力に矛盾しない範囲で X の値が変わる場合があります。

入出力例

以下は、N = 3 の場合の入出力例です。

入力 出力 説明
3 ジュースの本数 N が与えられます。
2 呼ぶ友人の数 M を出力します。
2 1 2 1 人目の友人にジュース 1 とジュース 2 を与えます。
1 2 2 人目の友人に、ジュース 2 を与えます。
10 翌日に各友人がお腹を壊したかどうかを表す文字列 S が与えられます。
1 腐ったジュースの番号を出力します。

Score: 425 points

Problem Statement

This is an interactive problem (a type of problem where your program interacts with the judge program through Standard Input and Output).

There are N bottles of juice, numbered 1 to N. It has been discovered that exactly one of these bottles has gone bad. Even a small sip of the spoiled juice will cause stomach upset the next day.

Takahashi must identify the spoiled juice by the next day. To do this, he decides to call the minimum necessary number of friends and serve them some of the N bottles of juice. He can give any number of bottles to each friend, and each bottle of juice can be given to any number of friends.

Print the number of friends to call and how to distribute the juice, then receive information on whether each friend has an upset stomach the next day, and print the spoiled bottle's number.

Constraints

  • N is an integer.
  • 2 \leq N \leq 100

Input/Output

This is an interactive problem (a type of problem where your program interacts with the judge program through Standard Input and Output).

Before the interaction, the judge secretly selects an integer X between 1 and N as the spoiled bottle's number. The value of X is not given to you. Also, the value of X may change during the interaction as long as it is consistent with the constraints and previous outputs.

First, the judge will give you N as input.

N

You should print the number of friends to call, M, followed by a newline.

M

Next, you should perform the following procedure to print M outputs. For i = 1, 2, \ldots, M, the i-th output should contain the number K_i of bottles of juice you will serve to the i-th friend, and the K_i bottles' numbers in ascending order, A_{i, 1}, A_{i, 2}, \ldots, A_{i, K_i}, separated by spaces, followed by a newline.

K_i A_{i, 1} A_{i, 2} \ldots A_{i, K_i}

Then, the judge will inform you whether each friend has a stomach upset the next day by giving you a string S of length M consisting of 0 and 1.

S

For i = 1, 2, \ldots, M, the i-th friend has a stomach upset if and only if the i-th character of S is 1.

You should respond by printing the number of the spoiled juice bottle X', followed by a newline.

X'

Then, terminate the program immediately.

If the M you printed is the minimum necessary number of friends to identify the spoiled juice out of the N bottles, and the X' you printed matches the spoiled bottle's number X, then your program is considered correct.

Notes

  • Each output should end with a newline and flushing Standard Output. Otherwise, you may receive a TLE verdict.
  • The verdict is indeterminate if your program prints an invalid output during the interaction or terminates prematurely. In particular, note that if a runtime error occurs during the execution of the program, the verdict may be or TLE instead of .
  • Terminate the program immediately after printing X'. Otherwise, the verdict is indeterminate.
  • The judge for this problem is adaptive, meaning that the value of X may change as long as it is consistent with the constraints and previous outputs.

Sample Input/Output

Below is an interaction with N = 3.

Input Output Description
3 The number of bottles, N, is given.
2 Print the number of friends to call, M.
2 1 2 Serve juice 1 and juice 2 to the first friend.
1 2 Serve juice 2 to the second friend.
10 The string S is given, indicating whether each friend has a stomach upset the next day.
1 Print the spoiled bottle's number.