CF1556D.Take a Guess
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述

This is an interactive task
William has a certain sequence of integers a1,a2,…,an in his mind, but due to security concerns, he does not want to reveal it to you completely. William is ready to respond to no more than 2⋅n of the following questions:
- What is the result of a bitwise AND of two items with indices i and j (i=j)
- What is the result of a bitwise OR of two items with indices i and j (i=j)
You can ask William these questions and you need to find the k-th smallest number of the sequence.
Formally the k-th smallest number is equal to the number at the k-th place in a 1-indexed array sorted in non-decreasing order. For example in array [5,3,3,10,1] 4th smallest number is equal to 5, and 2nd and 3rd are 3.

这是一个交互式题目。
威廉心中有一个整数序列 a1,a2,…,an,但由于安全考虑,他并不想将该序列完全透露给你。威廉最多会回答 2⋅n 个如下形式的问题:
你可以向威廉提出上述问题,你需要据此找出该序列中第 k 小的数。
形式化地,第 k 小的数定义为:将序列按非递减顺序排序后(下标从 1 开始),位于第 k 个位置上的数。例如,在数组 [5,3,3,10,1] 中,第 4 小的数是 5,而第 2 小和第 3 小的数均为 3。
输入格式
It is guaranteed that for each element in a sequence the condition 0≤ai≤109 is satisfied.
保证序列中每个元素均满足条件 0≤ai≤109。
输入输出样例
输入#1
7 6 2 7
输出#1
and 2 5 or 5 6 finish 5
说明/提示
In the example, the hidden sequence is [1,6,4,2,3,5,4].
Below is the interaction in the example.
Query (contestant's program)
Response (interactor)
Notes
and 2 5
2
a2=6, a5=3. Interactor returns bitwise AND of the given numbers.
or 5 6
7
a5=3, a6=5. Interactor returns bitwise OR of the given numbers.
finish 5
5 is the correct answer. Note that you must find the value and not the index of the kth smallest number.
在该示例中,隐藏序列为 [1,6,4,2,3,5,4]。
以下是该示例中的交互过程。
查询(选手程序)
响应(交互器)
说明
and 2 5
2
a2=6,a5=3。交互器返回所给两数的按位与(bitwise AND)结果。
or 5 6
7
a5=3,a6=5。交互器返回所给两数的按位或(bitwise OR)结果。
finish 5
5 是正确答案。注意:你必须找出第 k 小的数的值,而非其下标。
输入解题思路,AI测评打分。不知道怎么写?