CF1270D.Strange Device
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device can answer queries of the following form: in response to the positions of k different elements of the array, it will return the position and value of the m-th among them in the ascending order.
Unfortunately, the instruction for the device was lost during delivery. However, you remember k, but don't remember m. Your task is to find m using queries to this device.
You can ask not more than n queries.
Note that the array a and number m are fixed before the start of the interaction and don't depend on your queries. In other words, interactor is not adaptive.
Note that you don't have to minimize the number of queries, and you don't need to guess array a. You just have to guess m.
本题为交互式问题。
我们隐藏了一个包含 n 个互不相同的数的数组 a(即任意两个数均不相等)。你可以使用刚从亚马逊订购的一台新设备来获取该数组的部分信息。
该设备可响应如下形式的查询:给定数组中 k 个不同位置上的元素,设备将返回这 k 个元素中按升序排列的第 m 小的元素的位置和值。
不幸的是,该设备的说明书在运输途中遗失了。然而,你仍记得参数 k,却忘记了 m。你的任务是通过向该设备发出查询,确定出 m 的值。
你最多可进行 n 次查询。
注意:数组 a 和数值 m 在交互开始前即已固定,且不依赖于你所发出的查询。换言之,交互器(interactor)是非自适应的(non-adaptive)。
注意:你无需最小化查询次数,也无需还原出整个数组 a;你只需正确猜出 m 的值即可。
输入格式
The first line contains two integers n and k (1≤k<n≤500) — the length of the array and the number of the elements in the query.
It is guaranteed that number m satisfies 1≤m≤k, elements a1,a2,…,an of the array satisfy 0≤ai≤109, and all of them are different.
第一行包含两个整数 n 和 k(1≤k<n≤500)—— 分别表示数组的长度和查询中元素的个数。
保证数字 m 满足 1≤m≤k,数组元素 a1,a2,…,an 满足 0≤ai≤109,且所有元素互不相同。
输入输出样例
输入#1
4 3 4 9 4 9 4 9 1 2
输出#1
? 2 3 4 ? 1 3 4 ? 1 2 4 ? 1 2 3 ! 3
说明/提示
In the example, n=4, k=3, m=3, a=[2,0,1,9].
在示例中,n=4,k=3,m=3,a=[2,0,1,9]。
输入解题思路,AI测评打分。不知道怎么写?