103374: [Atcoder]ABC337 E - Bad Juice

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:2 Solved:0

Description

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.

Output

得分:425分

问题描述

这是一个交互式问题(一种通过标准输入和输出与裁判程序交互的问题)。

有$N$瓶果汁,编号为$1$到$N$。已经发现其中正好有一瓶变质了。即使是小小一口变质的果汁也会导致第二天胃部不适。

高桥必须在第二天之前识别出变质的果汁。为此,他决定召唤最小必要数量的朋友,并给他们品尝这$N$瓶果汁。他可以给每个朋友任意数量的瓶子,而每瓶果汁可以给任意数量的朋友。

打印要召唤的朋友数量以及如何分发果汁,然后接收关于第二天每个朋友是否有胃部不适的信息,并打印出变质瓶子的编号。

约束条件

  • $N$是一个整数。
  • $2 \leq N \leq 100$

输入/输出

这是一个交互式问题(一种通过标准输入和输出与裁判程序交互的问题)。

在交互之前,裁判会秘密选择一个在$1$到$N$之间的整数$X$作为变质瓶子的编号。$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$,如果$S$的第$i$个字符是1,则第$i$个朋友有胃部不适。

你应该通过打印变质果汁瓶的编号$X'$来回应,后面跟着一个换行符。

$X'$

然后立即终止程序。

如果你打印的$M$是识别$N$瓶果汁中变质果汁的最小必要朋友数量,且你打印的$X'$与变质瓶子的编号$X$匹配,则你的程序被认为是正确的。

注意

  • 每个输出应该以换行符和刷新标准输出结尾。否则,你可能会收到一个TLE

Sample Input Copy


Sample Output Copy


HINT

n瓶药水,其中一瓶是毒药,喝下后第二天会出现异常,请问至少多少人试药,第二天能辨别出哪瓶是毒药?怎么安排试药?怎么辨别出来?

加入题单

上一题 下一题 算法标签: