CF BUDDY
← Problems·

1270D · Strange Device

1900 · constructive algorithms, interactive, math

Problem: 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.

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

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

Note: In the example, n=4n = 4, k=3k = 3, m=3m = 3, a=[2,0,1,9]a = [2, 0, 1, 9].

Sample Cases

Case 1

Input

4 3
4 9
4 9
4 9
1 2

Output

? 2 3 4
? 1 3 4
? 1 2 4
? 1 2 3
! 3

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback