310049: CF1776C. Library game

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

Description

Library game

题目描述

Alessia and Bernardo are discovering the world of competitive programming through the books of their university library. The library consists of $ m $ sections numbered from $ 1 $ to $ m $ . Each section contains only books dedicated to a particular subject and different sections correspond to different subjects. In order to prevent the students from wandering in the library, the university has established a system of passes. Each pass has a length $ y $ associated to it and allows access to an interval of $ y $ consecutive sections in the library. During a visit, the student must choose exactly one book from one of these sections and leave the library. Each pass can be used only once. At the moment Alessia and Bernardo have $ n $ passes of lengths $ x_1, \, x_2, \, \dots, \, x_n $ . They have different opinions on the best way to improve: Alessia thinks that it is important to study many different topics, while Bernardo believes that it is important to study deeply at least one topic. So, Alessia wants to use the $ n $ passes to get $ n $ books on distinct topics, while Bernardo would like to get at least two books on the same topic. They have reached the following agreement: for each of the following $ n $ days, Alessia will choose a pass of length $ y $ among those which are still available and an interval of $ y $ sections in the library, and Bernardo will go into the library and will take exactly one book from one of those sections. Can Bernardo manage to get at least two books on the same subject, or will Alessia be able to avoid it? You should decide whether you want to be Alessia or Bernardo, and you have to fulfill the goal of your chosen character. The judge will impersonate the other character. Note that, even if at some moment Bernardo has already taken two books on the same subject, the interaction should go on until the end of the $ n $ days.

输入输出格式

输入格式


The first line contains two integers $ n $ and $ m $ ( $ 1 \le n \le 100 $ , $ n \le m \le 5000 $ ) — the number of passes and the number of sections. The second line contains $ n $ integers $ x_1, \, x_2, \, \dots, \, x_n $ ( $ 1 \le x_i \le m $ ) — the lengths of the passes available.

输出格式


First, you should print a line containing either the string $ \texttt{Alessia} $ or the string $ \texttt{Bernardo} $ — the character that you want to impersonate. Then, for each of the $ n $ turns: - If you are taking the role of Alessia, print a single line consisting of two integers $ y $ and $ a $ ( $ 1 \le a \le m - y + 1 $ ) — you are choosing a pass of length $ y $ and the interval of sections $ [a, a + y - 1] $ . Note that at least one pass of length $ y $ must still be available. After this, read a single integer $ b $ ( $ a \le b \le a + y - 1 $ ) — the subject of the book selected by Bernardo. - If you are taking the role of Bernardo, read two integers $ y $ and $ a $ ( $ 1 \le a \le m - y + 1 $ ) — the length of the pass chosen by Alessia and the index of the first section of the interval. It is guaranteed that there is at least one pass of length $ y $ available. Then, print a line consisting of a single integer $ b $ ( $ a \le b \le a + y - 1 $ ) — the subject from which you choose to take a book. If one of your interactions is malformed, the interactor terminates immediately and your program receives the verdict $ \texttt{WRONG-ANSWER} $ . Otherwise, you will receive the verdict according to the game's criteria described above. After printing a line do not forget to end the line and flush the output. Otherwise, you will get the verdict $ \texttt{TIMELIMIT} $ . To flush the output, use: - $ \texttt{fflush(stdout)} $ in C; - $ \texttt{fflush(stdout)} $ , $ \texttt{cout <}\texttt{< flush} $ or $ \texttt{cout.flush()} $ in C++; - $ \texttt{System.out.flush()} $ in Java and Kotlin; - $ \texttt{sys.stdout.flush()} $ in Python.

输入输出样例

输入样例 #1

5 14
3 7 2 3 10

输出样例 #1

-

输入样例 #2

4 10
4 1 6 4

输出样例 #2

-

说明

In the first sample, it can be shown that Alessia can accomplish her goal. An example of interaction (after reading the input) follows: $ $ \begin{array}{|c|c|c|} \hline \textbf{Contestant} & \textbf{Judge} & \textbf{Explanation} \\ \hline \texttt{Alessia} & & \text{The program will act as Alessia} \\ \hline 3 \quad 11 & & \text{Choose $y = 3$ and $a = 11$} \\ \hline & 13 & \text{Judge selects $b = 13$} \\ \hline 10 \quad 2 & & \text{Choose $y = 10$ and $a = 2$} \\ \hline & 9 & \text{Judge selects $b = 9$} \\ \hline 7 \quad 1 & & \text{Choose $y = 7$ and $a = 1$} \\ \hline & 4 & \text{Judge selects $b = 4$} \\ \hline 2 \quad 10 & & \text{Choose $y = 2$ and $a = 10$} \\ \hline & 10 & \text{Judge selects $b = 10$} \\ \hline 3 \quad 6 & & \text{Choose $y = 3$ and $a = 6$} \\ \hline & 7 & \text{Judge selects $b = 7$} \\ \hline \end{array} $ $ </p><p>The program of the contestant wins because all the books chosen by Bernardo pertain to different topics. The actions performed by the contestant and the judge in this example of interaction may be non-optimal.</p><p>In the <span class="tex-font-style-bf">second sample</span>, it can be shown that Bernardo can manage to fulfil his goal. An example of interaction (after reading the input) follows:</p><p> $ $ \begin{array}{|c|c|c|} \hline \textbf{Contestant} & \textbf{Judge} & \textbf{Explanation} \\ \hline \texttt{Bernardo} & & \text{The program will act as Bernardo} \\ \hline & 4 \quad 1 & \text{Judge chooses $y = 4$ and $a = 1$} \\ \hline 4 & & \text{Select $b = 4$} \\ \hline & 1 \quad 10 & \text{Judge chooses $y = 1$ and $a = 10$} \\ \hline 10 & & \text{Select $b = 10$} \\ \hline & 6 \quad 3 & \text{Judge chooses $y = 6$ and $a = 3$} \\ \hline 4 & & \text{Select $b = 4$} \\ \hline & 4 \quad 5 & \text{Judge chooses $y = 4$ and $a = 5$} \\ \hline 8 & & \text{Select $b = 8$} \\ \hline \end{array} $ $ </p><p>The program of the contestant wins because Bernardo has selected two books on topic number $ 4$. The actions performed by the contestant and the judge in this example of interaction may be non-optimal.

Input

题意翻译

有一个长度为 $m$ 的书架,以及 $n$ 个长度 $a_1,\dots,a_n$ 。 Alessia 和 Bernardo 从书架上取书。每次由 Alessia 选择一个之前没选过的 $i$ ,并选择一个长度为 $a_i$ 的区间,需要保证这个区间内的书全都没有被取过。然后 Bernardo 从区间内任意拿走一本书。 Bernardo 的目标是让 Alessia 某一步没有区间可选。输出谁赢,并交互构造方案。 $n \le 100, m \le 5000$

Output

**图书馆游戏**

**题目描述:**
Alessia和Bernardo通过大学图书馆的书籍发现竞技编程的世界。图书馆由m个区域组成,编号从1到m。每个区域只包含专用于特定主题的书籍,不同的区域对应不同的主题。为了防止学生在图书馆闲逛,大学建立了一个通行证系统。每张通行证都有一个与之关联的长度y,允许进入图书馆中连续y个区域的范围。在访问期间,学生必须从这些区域中选择一本精确的书籍并离开图书馆。每张通行证只能使用一次。

目前,Alessia和Bernardo有n张通行证,长度分别为x1, x2, ..., xn。他们对最佳改进方式有不同的看法:Alessia认为研究许多不同的话题很重要,而Bernardo认为深入研究至少一个话题很重要。所以,Alessia想要使用这n张通行证来获得n本不同主题的书籍,而Bernardo则想至少获得两本同一主题的书籍。

他们达成了以下协议:在接下来的n天里,Alessia将选择一张长度为y的通行证,这些通行证仍然可用,并选择图书馆中的一个y区域范围,然后Bernardo将进入图书馆,并从这些区域中精确选择一本书。

Bernardo能否设法获得至少两本同一主题的书籍,还是Alessia能够避免这种情况?

你需要决定你想成为Alessia还是Bernardo,并且你必须完成你选择角色的目标。裁判员将扮演另一个角色。注意,即使Bernardo已经拿到了两本同一主题的书籍,互动也应该继续进行,直到n天结束。

**输入输出格式:**

**输入格式:**
第一行包含两个整数n和m(1≤n≤100,n≤m≤5000)——通行证的数量和区域数量。

第二行包含n个整数x1, x2, ..., xn(1≤xi≤m)——可用通行证的长度。

**输出格式:**
首先,你应该打印一行,包含字符串"Alessia"或字符串"Bernardo"——你想要扮演的角色。

然后,对于每个n轮:
- 如果你扮演Alessia,打印一行,包含两个整数y和a(1≤a≤m-y+1)——你选择了一张长度为y的通行证和区域范围[a, a+y-1]。注意,至少必须还有一张长度为y的通行证可用。在此之后,读取一个整数b(a≤b≤a+y-1)——Bernardo选择的书籍主题。
- 如果你扮演Bernardo,读取两个整数y和a(1≤a≤m-y+1)——Alessia选择的通行证长度和区间的第一个区域索引。保证至少有一张长度为y的通行证可用。然后,打印一行,包含一个整数b(a≤b≤a+y-1)——你选择从中拿书的主题。

如果其中一次互动格式错误,互动立即终止,你的程序将收到WRONG-ANSWER的裁决。否则,你将根据游戏上述标准收到裁决。

打印完一行后,不要忘记结束该行并刷新输出。否则,你将得到TIMELIMIT的裁决。刷新输出,使用:
- 在C语言中使用fflush(stdout);
- 在C++中使用fflush(stdout),cout << flush或cout.flush();
- 在Java和Kotlin中使用System.out.flush();
- 在Python中使用sys.stdout.flush()。

**输入输出样例:**

**输入样例 #1:**
```
5 14
3 7 2 3 10
```
**输出样例 #1:**
```
-
```

**输入样例 #2:**
```
4 10
4 1 6 4
```
**输出样例 #2:**
```
-
```

**说明:**
在第一个样例中,可以证明Alessia能够实现她的目标。互动的例子(在读取输入后)如下:

```
Contestant Judge Explanation
Alessia The program will act as Alessia
3 11 Choose y = 3 and a = 11
13 Judge selects b = 13
10 2 Choose y = 10 and a = 2
9 Judge selects b = 9
7 1 Choose y = 7 and a = 1
4 Judge selects b = 4
2 10 Choose y = 2 and a = 10
10 Judge selects b = 10
3 6 Choose y = 3 and a = 6
7 Judge selects b = 7
```

参赛者的程序获胜,因为Bernardo选择的书籍都属于不同的主题。在这个互动例子中,参赛者和裁判员执行的动作可能不是最优的。

在第二个样例中,可以证明Bernardo能够实现他的目标。互动的例子(在读取输入后)如下**图书馆游戏** **题目描述:** Alessia和Bernardo通过大学图书馆的书籍发现竞技编程的世界。图书馆由m个区域组成,编号从1到m。每个区域只包含专用于特定主题的书籍,不同的区域对应不同的主题。为了防止学生在图书馆闲逛,大学建立了一个通行证系统。每张通行证都有一个与之关联的长度y,允许进入图书馆中连续y个区域的范围。在访问期间,学生必须从这些区域中选择一本精确的书籍并离开图书馆。每张通行证只能使用一次。 目前,Alessia和Bernardo有n张通行证,长度分别为x1, x2, ..., xn。他们对最佳改进方式有不同的看法:Alessia认为研究许多不同的话题很重要,而Bernardo认为深入研究至少一个话题很重要。所以,Alessia想要使用这n张通行证来获得n本不同主题的书籍,而Bernardo则想至少获得两本同一主题的书籍。 他们达成了以下协议:在接下来的n天里,Alessia将选择一张长度为y的通行证,这些通行证仍然可用,并选择图书馆中的一个y区域范围,然后Bernardo将进入图书馆,并从这些区域中精确选择一本书。 Bernardo能否设法获得至少两本同一主题的书籍,还是Alessia能够避免这种情况? 你需要决定你想成为Alessia还是Bernardo,并且你必须完成你选择角色的目标。裁判员将扮演另一个角色。注意,即使Bernardo已经拿到了两本同一主题的书籍,互动也应该继续进行,直到n天结束。 **输入输出格式:** **输入格式:** 第一行包含两个整数n和m(1≤n≤100,n≤m≤5000)——通行证的数量和区域数量。 第二行包含n个整数x1, x2, ..., xn(1≤xi≤m)——可用通行证的长度。 **输出格式:** 首先,你应该打印一行,包含字符串"Alessia"或字符串"Bernardo"——你想要扮演的角色。 然后,对于每个n轮: - 如果你扮演Alessia,打印一行,包含两个整数y和a(1≤a≤m-y+1)——你选择了一张长度为y的通行证和区域范围[a, a+y-1]。注意,至少必须还有一张长度为y的通行证可用。在此之后,读取一个整数b(a≤b≤a+y-1)——Bernardo选择的书籍主题。 - 如果你扮演Bernardo,读取两个整数y和a(1≤a≤m-y+1)——Alessia选择的通行证长度和区间的第一个区域索引。保证至少有一张长度为y的通行证可用。然后,打印一行,包含一个整数b(a≤b≤a+y-1)——你选择从中拿书的主题。 如果其中一次互动格式错误,互动立即终止,你的程序将收到WRONG-ANSWER的裁决。否则,你将根据游戏上述标准收到裁决。 打印完一行后,不要忘记结束该行并刷新输出。否则,你将得到TIMELIMIT的裁决。刷新输出,使用: - 在C语言中使用fflush(stdout); - 在C++中使用fflush(stdout),cout << flush或cout.flush(); - 在Java和Kotlin中使用System.out.flush(); - 在Python中使用sys.stdout.flush()。 **输入输出样例:** **输入样例 #1:** ``` 5 14 3 7 2 3 10 ``` **输出样例 #1:** ``` - ``` **输入样例 #2:** ``` 4 10 4 1 6 4 ``` **输出样例 #2:** ``` - ``` **说明:** 在第一个样例中,可以证明Alessia能够实现她的目标。互动的例子(在读取输入后)如下: ``` Contestant Judge Explanation Alessia The program will act as Alessia 3 11 Choose y = 3 and a = 11 13 Judge selects b = 13 10 2 Choose y = 10 and a = 2 9 Judge selects b = 9 7 1 Choose y = 7 and a = 1 4 Judge selects b = 4 2 10 Choose y = 2 and a = 10 10 Judge selects b = 10 3 6 Choose y = 3 and a = 6 7 Judge selects b = 7 ``` 参赛者的程序获胜,因为Bernardo选择的书籍都属于不同的主题。在这个互动例子中,参赛者和裁判员执行的动作可能不是最优的。 在第二个样例中,可以证明Bernardo能够实现他的目标。互动的例子(在读取输入后)如下

加入题单

上一题 下一题 算法标签: