E1. Mexness (Easy Version)

Codeforces
IDCFE1
Time4000ms
Memory512MB
Difficulty
English · Original
Chinese · Translation
Formal · Original
*This is the easy version of the problem. The only difference is the maximum number of queries.* *This is an interactive problem.* There is a secret permutation $p_0, p_1, \\dots, p_{n -1}$, which is a permutation of ${0, 1, \\dots, n -1}$. There is also a variable $m x$. At first, $m x = 4$. Your task is to guess the permutation by using queries of the following type: The $"mex"(a)$ of an array $a$ is defined as the smallest non-negative integer that does not appear in $a$. For example, if $a = [ 0, 1, 2, 4 ]$, then $"mex"(a) = 3$ because $3$ is the smallest non-negative integer not present in $a$. Find out the secret permutation using at most $9 n + 1$ queries of the second type. Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 <= t <= 200$). The description of the test cases follows. The first line of each test case contains one integer $n$ ($2 <= n <= 1024$). It is guaranteed that the sum of $n$ over all test cases will not exceed $1024$. At this moment, the permutation $p_0, p_1, \\dots, p_{n -1}$ is chosen. The interactor in this task is *not adaptive*. In other words, the sequence $p$ is fixed in every test case and does not change during the interaction. Then you can make queries. To make a query of the first type, output a line in the format "! $i$ $v$" (without quotes). Note that this line is *not* included in the count of $9 n + 1$ queries of the second type. To make a query of the second type, output a line in the format "? $k$ $j_1$ $j_2$ $\\dots$ $j_k$" (without quotes) ($1 <= k <= n$, $0 <= j_i < n$). After each query, read an integer — the answer to your query. After performing $n$ queries of the first type (in other words, you have guessed the entire permutation $p$), if this is the last test case, the jury will terminate the program. Otherwise, the jury will output the next $n$. After printing each line, do not forget to output the end of line and flush the output buffer. Otherwise, you will receive the _Idleness limit exceeded verdict_. To flush, use: In the first test case, the hidden permutation $p$ is $[ 2, 0, 1 ]$. For the query "_? 2 1 0_", the jury returns $1$ because $min (m x, "mex"(p_1, p_0)) = min (4, 1) = 1$. Then, for answer "_! 2 1_", the jury increases $m x$ by $1$ since the answer is correct and you haven't answered for $p_2$ twice. For the query "_? 1 0_", the jury returns $0$ because $min (m x, "mex"(p_0)) = min (5, 0) = 0$. Note queries are only for understanding statements and do *not* guarantee finding a unique permutation $p$. ## Input Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 <= t <= 200$). The description of the test cases follows. ## Interaction The first line of each test case contains one integer $n$ ($2 <= n <= 1024$). It is guaranteed that the sum of $n$ over all test cases will not exceed $1024$.At this moment, the permutation $p_0, p_1, \\dots, p_{n -1}$ is chosen. The interactor in this task is *not adaptive*. In other words, the sequence $p$ is fixed in every test case and does not change during the interaction.Then you can make queries.To make a query of the first type, output a line in the format "! $i$ $v$" (without quotes). Note that this line is *not* included in the count of $9 n + 1$ queries of the second type.To make a query of the second type, output a line in the format "? $k$ $j_1$ $j_2$ $\\dots$ $j_k$" (without quotes) ($1 <= k <= n$, $0 <= j_i < n$). After each query, read an integer — the answer to your query.After performing $n$ queries of the first type (in other words, you have guessed the entire permutation $p$), if this is the last test case, the jury will terminate the program. Otherwise, the jury will output the next $n$.After printing each line, do not forget to output the end of line and flush the output buffer. Otherwise, you will receive the _Idleness limit exceeded verdict_. To flush, use: _fflush(stdout)_ or _cout.flush()_ in C++; _System.out.flush()_ in Java; _stdout.flush()_ in Python; see the documentation for other languages. [samples] ## Note In the first test case, the hidden permutation $p$ is $[ 2, 0, 1 ]$.For the query "_? 2 1 0_", the jury returns $1$ because $min (m x, "mex"(p_1, p_0)) = min (4, 1) = 1$.Then, for answer "_! 2 1_", the jury increases $m x$ by $1$ since the answer is correct and you haven't answered for $p_2$ twice.For the query "_? 1 0_", the jury returns $0$ because $min (m x, "mex"(p_0)) = min (5, 0) = 0$.Note queries are only for understanding statements and do *not* guarantee finding a unique permutation $p$.
*这是该问题的简单版本。两个版本之间的唯一区别在于查询中不同数字 $a$ 的数量限制。在本版本中,该限制不存在。* *这是一个交互式问题。* 你和爱普丽尔·奥尼尔被困在巴克斯特·斯托克曼的实验室中。一群长着尖牙的老鼠夹正向你们逼近。唯一的逃生方法是猜出一个秘密密码——一个数字 $p$($3 lt.eq p lt.eq 10^6$),用它来停用它们。爱普丽尔曾在此实验室工作,记得数字 $p$ 一定是 *质数*,因为最可靠的加密算法都使用质数。 在老鼠夹的控制面板上,你们发现了一个漏洞。它允许你发出查询:“数字 $p$ 是否与 $d$ 模 $a$ 同余?”。换句话说:“$p - d$ 是否能被 $a$ 整除?”。你可以为每次查询自行指定 $a$ 和 $d$。 如果你违反了交互格式,或进行了 *超过* $1000$ 次查询,老鼠夹的自毁协议将被触发,你将陷入危险。 请帮助爱普丽尔破解控制面板并停用老鼠夹。 你最多可以进行 *1000* 次查询,包括输出答案。 交互器 *不是* 自适应的,即数字 $p$ 是固定的,且 *不会* 随查询改变。 交互器接受如下格式的查询: 在输出查询后,请务必输出换行符并刷新输出缓冲区。否则你将获得 “解决方案挂起” 的 verdict。如果你使用 _C++_,出题组建议不要启用输入/输出加速,并使用 _std::endl_ 作为换行符。 交互器将返回一个数字作为响应: 当你准备好说出数字 $p$($3 lt.eq p lt.eq 10^6$)时,请以如下格式输出: 在输出秘密密码后,你的程序必须立即终止,否则出题组不保证 verdict 的正确性。 ## Пример 输入 ? 2 1 ? 3 1 ? 3 2 ! 3 输出 1 0 0 ## Протокол Взаимодействия 你最多可以进行 *1000* 次查询,包括输出答案。交互器 *不是* 自适应的,即数字 $p$ 是固定的,且 *不会* 随查询改变。交互器接受如下格式的查询: _?_ $a$ $d$($2 lt.eq a lt.eq 2 dot.op 10^6$,$0 lt.eq d < a$) 在输出查询后,请务必输出换行符并刷新输出缓冲区。否则你将获得 “解决方案挂起” 的 verdict。如果你使用 _C++_,出题组建议不要启用输入/输出加速,并使用 _std::endl_ 作为换行符。 交互器将返回一个数字作为响应: $0$,表示数字 $p$ *不* 与 $d$ 模 $a$ 同余; $1$,否则。 当你准备好说出数字 $p$($3 lt.eq p lt.eq 10^6$)时,请以如下格式输出: _!_ $p$ 在输出秘密密码后,你的程序必须立即终止,否则出题组不保证 verdict 的正确性。 [samples]
**Definitions** Let $ p \in \mathbb{P} $ be the unknown prime such that $ 3 \leq p \leq 10^6 $. **Constraints** - You may make at most $ 1000 $ queries. - Each query: choose integers $ a > 1 $, $ d $ with $ 0 \leq d < a $, and ask whether $ p \equiv d \pmod{a} $. - The interactor responds with $ 1 $ if $ p \equiv d \pmod{a} $, else $ 0 $. **Objective** Identify $ p $ using at most $ 1000 $ adaptive queries of the form $ p \stackrel{?}{\equiv} d \pmod{a} $.
API Response (JSON)
{
  "problem": {
    "name": "E1. Mexness (Easy Version)",
    "description": {
      "content": "*This is the easy version of the problem. The only difference is the maximum number of queries.* *This is an interactive problem.* There is a secret permutation $p_0, p_1, \\\\dots, p_{n -1}$, which i",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 4000,
      "memory_limit": 524288
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CFE1"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "*This is the easy version of the problem. The only difference is the maximum number of queries.*\n\n*This is an interactive problem.*\n\nThere is a secret permutation $p_0, p_1, \\\\dots, p_{n -1}$, which i...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "*这是该问题的简单版本。两个版本之间的唯一区别在于查询中不同数字 $a$ 的数量限制。在本版本中,该限制不存在。*\n\n*这是一个交互式问题。*\n\n你和爱普丽尔·奥尼尔被困在巴克斯特·斯托克曼的实验室中。一群长着尖牙的老鼠夹正向你们逼近。唯一的逃生方法是猜出一个秘密密码——一个数字 $p$($3 lt.eq p lt.eq 10^6$),用它来停用它们。爱普丽尔曾在此实验室工作,记得数字 $p$ 一...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ p \\in \\mathbb{P} $ be the unknown prime such that $ 3 \\leq p \\leq 10^6 $.  \n\n**Constraints**  \n- You may make at most $ 1000 $ queries.  \n- Each query: choose integers $ a > 1 ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments