CF1270D.Strange Device

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This problem is interactive.

We have hidden an array aa of nn 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 kk different elements of the array, it will return the position and value of the mm-th among them in the ascending order.

Unfortunately, the instruction for the device was lost during delivery. However, you remember kk, but don't remember mm. Your task is to find mm using queries to this device.

You can ask not more than nn queries.

Note that the array aa and number mm 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 aa. You just have to guess mm.

本题为交互式问题。

我们隐藏了一个包含 nn 个互不相同的数的数组 aa(即任意两个数均不相等)。你可以使用刚从亚马逊订购的一台新设备来获取该数组的部分信息。

该设备可响应如下形式的查询:给定数组中 kk 个不同位置上的元素,设备将返回这 kk 个元素中按升序排列的第 mm 小的元素的位置和值。

不幸的是,该设备的说明书在运输途中遗失了。然而,你仍记得参数 kk,却忘记了 mm。你的任务是通过向该设备发出查询,确定出 mm 的值。

你最多可进行 nn 次查询。

注意:数组 aa 和数值 mm 在交互开始前即已固定,且不依赖于你所发出的查询。换言之,交互器(interactor)是非自适应的(non-adaptive)。

注意:你无需最小化查询次数,也无需还原出整个数组 aa;你只需正确猜出 mm 的值即可。

输入格式

The first line contains two integers nn and kk (1≤k<n≤5001\le k \lt n \le 500) — the length of the array and the number of the elements in the query.

It is guaranteed that number mm satisfies 1≤m≤k1\le m \le k, elements a1,a2,…,ana_1, a_2, \dots, a_n of the array satisfy 0≤ai≤1090\le a_i \le 10^9, and all of them are different.

第一行包含两个整数 nn 和 kk(1≤k<n≤5001\le k \lt n \le 500)—— 分别表示数组的长度和查询中元素的个数。

保证数字 mm 满足 1≤m≤k1\le m \le k,数组元素 a1,a2,…,ana_1, a_2, \dots, a_n 满足 0≤ai≤1090\le a_i \le 10^9,且所有元素互不相同。

输入输出样例

  • 输入#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=4n = 4, k=3k = 3, m=3m = 3, a=[2,0,1,9]a = [2, 0, 1, 9].

在示例中,n=4n = 4,k=3k = 3,m=3m = 3,a=[2,0,1,9]a = [2, 0, 1, 9]。

输入解题思路,AI测评打分。不知道怎么写?

首页