CF809B.Glad to see you!
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is an interactive problem. In the output section below you will see the information about flushing the output.
On Sunday Leha the hacker took Nura from the house where she lives and went with her to one of the most luxurious restaurants in Vičkopolis. Upon arrival, they left the car in a huge parking lot near the restaurant and hurried inside the building.
In the restaurant a polite waiter immediately brought the menu to Leha and Noora, consisting of n dishes. It is interesting that all dishes in the menu are numbered with integers from 1 to n. After a little thought, the girl ordered exactly k different dishes from available in the menu. To pass the waiting time while the chefs prepare ordered dishes, the girl invited the hacker to play a game that will help them get to know each other better.
The game itself is very simple: Noora wants Leha to guess any two dishes among all ordered. At the same time, she is ready to answer only one type of questions. Leha can say two numbers x and y (1 ≤ x, y ≤ n). After that Noora chooses some dish a for the number x such that, at first, a is among the dishes Noora ordered (x can be equal to a), and, secondly, the value
is the minimum possible. By the same rules the girl chooses dish b for y. After that Noora says «TAK» to Leha, if
, and «NIE» otherwise. However, the restaurant is preparing quickly, so Leha has enough time to ask no more than 60 questions. After that he should name numbers of any two dishes Noora ordered.
Help Leha to solve this problem!
这是一个交互式问题。在下方的输出部分,你将看到有关刷新输出的信息。
星期天,黑客 Leha 将 Nura 从她居住的家中接出,带她前往 Vičkopolis 最豪华的餐厅之一。到达后,他们将车停在餐厅附近一个巨大的停车场里,然后匆匆进入大楼。
在餐厅内,一位礼貌的服务员立即为 Leha 和 Noora 呈上了菜单,菜单上共有 n 道菜肴。有趣的是,菜单上的所有菜肴均用 1 到 n 的整数编号。稍作思考后,这位女孩从菜单中恰好点了 k 道互不相同的菜肴。为了打发厨师准备所点菜肴的等待时间,女孩邀请黑客玩一个有助于彼此更好了解的游戏。
游戏本身非常简单:Noora 希望 Leha 猜出她所点的所有菜肴中的任意两道。同时,她只愿意回答一种类型的问题。Leha 可以报出两个数字 x 和 y(其中 1 ≤ _x_, _y_ ≤ _n)。随后,Noora 将为 x 选择某一道菜肴 a,满足:第一,a 是 Noora 所点的菜肴之一(注意 x 可能等于 a);第二,表达式
的值尽可能小。同样地,她也按相同规则为 y 选择一道菜肴 b。之后,若
,Noora 就对 Leha 说 «TAK»;否则说 «NIE»。然而,餐厅上菜速度很快,因此 Leha 最多只有时间提出不超过 60 个问题。在此之后,他必须准确说出 Noora 所点的任意两道菜肴的编号。
请帮助 Leha 解决这个问题!
输入格式
There are two numbers n and k (2 ≤ k ≤ n ≤ 105) in the single line of input denoting the number of dishes in the menu and the number of dishes Noora ordered.
输入仅有一行,包含两个整数 n 和 k(2 ≤ k ≤ n ≤ 105),分别表示菜单中的菜品总数以及诺拉点的菜品数量。
输出格式
If you want to provide an answer, output a string of the form 2 x y (1 ≤ x, y ≤ n, x ≠ y), if you think the dishes x and y was among dishes ordered by Noora. After that, flush the output and terminate your program.
如果你想提供答案,请输出形如 2 _x_ _y_(其中 1 ≤ x, y ≤ n,且 x = y)的字符串,表示你认为菜肴 x 和 y 是诺拉点的菜。之后,请刷新输出并终止程序。
输入输出样例
输入#1
3 2 NIE TAK NIE TAK TAK TAK
输出#1
1 1 2 1 2 1 1 1 3 1 3 1 1 2 3 1 3 2 2 2 3
说明/提示
There are three dishes in sample. Noora ordered dished numberes 2 and 3, which Leha should guess. If Noora receive requests for the first dish (x = 1), then she'll choose the second dish (a = 2) as the dish with the minimum value
. For the second (x = 2) and the third (x = 3) dishes themselves will be optimal, because in that case
.
Let Leha asks Noora about the next couple of dishes:
- x = 1, y = 2, then he'll recieve «NIE» answer, because |1 - 2| > |2 - 2|
- x = 2, y = 1, then he'll recieve «TAK» answer, because |2 - 2| ≤ |1 - 2|
- x = 1, y = 3, then he'll recieve «NIE» answer, because |1 - 2| > |3 - 3|
- x = 3, y = 1, then he'll recieve «TAK» answer, because |3 - 3| ≤ |1 - 2|
- x = 2, y = 3, then he'll recieve «TAK» answer, because |2 - 2| ≤ |3 - 3|
- x = 3, y = 2, then he'll recieve «TAK» answer, because |3 - 3| ≤ |2 - 2|
According to the available information, it is possible to say that Nura ordered dishes with numbers 2 and 3.
样例中有三道菜。诺拉点了编号为 2 和 3 的两道菜,莱哈需要猜出这两道菜的编号。若诺拉收到关于第一道菜的询问(即 x=1),则她会选择第二道菜(即 a=2)作为取值最小的菜,因为此时有
。而对于第二道菜(x=2)和第三道菜(x=3)本身,它们各自即为最优选择,因为此时有
。
假设莱哈向诺拉询问如下几组菜品:
- x=1, y=2,他将收到回答「NIE」,因为 ∣1−2∣>∣2−2∣;
- x=2, y=1,他将收到回答「TAK」,因为 ∣2−2∣≤∣1−2∣;
- x=1, y=3,他将收到回答「NIE」,因为 ∣1−2∣>∣3−3∣;
- x=3, y=1,他将收到回答「TAK」,因为 ∣3−3∣≤∣1−2∣;
- x=2, y=3,他将收到回答「TAK」,因为 ∣2−2∣≤∣3−3∣;
- x=3, y=2,他将收到回答「TAK」,因为 ∣3−3∣≤∣2−2∣。
根据以上信息,可以确定诺拉点的菜的编号为 2 和 3。
输入解题思路,AI测评打分。不知道怎么写?