C. Find the Array

Codeforces
IDCF10239C
Time2000ms
Memory256MB
Difficulty
English · Original
Formal · Original
_This is an interactive problem._ There is an array $a$ of length $n$, consisting of *distinct* integers. It is guaranteed that every element of the array is a positive integer less than or equal to $10^9$. You have to find out the values of all the elements of it. To do so, you can make up to $30$ queries of the following two types: Once you know the answer, print it using the following query: At the beginning, your program should read one integer $n$ ($1 <= n <= 250$) — the number of elements. In order to make a query of the first type, print "_1 $i$_" ($1 <= i <= n$). After this query, read one integer — the value of $a_i$. In order to make a query of the second type, print "_2 $k$_" ($2 <= k <= n$). Then in the same line print $k$ space-separated distinct integers — $i_1, i_2, \\dots, i_k$, ($1 <= i_j <= n$). After this query read $frac(k dot.op (k -1), 2)$ integers — $mid a_{i_c} -a_{i_d} mid$ for every $c < d$. These values will be given in random order. Once you know the answer, print "_3_". Then in the same line, print $n$ space-separated integers — $a_1, a_2, \\dots, a_n$ ($1 <= a_i <= 10^9$). Your program must terminate after this query. If for either of two first queries you get one number $-1$ as the answer, then it means that you made more queries than allowed, or made an invalid query. Your program should immediately terminate (for example, by calling _exit(0)_). You will receive "_Wrong Answer_". If you ignore this, you can get other verdicts since your program will continue to read from a closed stream. After printing a query do not forget to output end of line and flush the output. Otherwise, you will get _Wall time-limit exceeded_. To do this, use: Precisely follow this format of interaction. In the first query of type $1$, we ask the value of $a_1$ and receive $1$ as the answer. In the second query of type $2$, we ask the value of $a_2$ and receive $2$ as the answer. In the query of type $2$, we ask all the possible differences between the elements of array with indexes $1$, $2$ and $3$. And we get array $4, 3, 1$ as the result. We know that the array contains values $| a_1 -a_2 |, | a_1 -a_3 |, | a_2 -a_3 |$. Since we already know that $| a_2 -a_1 | = 1$, one of the following is true: $| a_1 -a_3 | = 3$ and $| a_2 -a_3 | = 4$ or $| a_2 -a_3 | = 3$ and $| a_1 -a_3 | = 4$. The only case that is possible, taking into account the constraints of the problem, is when $| a_1 -a_3 | = 4$ and $| a_2 -a_3 | = 3$ with $a_3 = 5$. Since we know the values of all the elements of the array, we print them in the last query. ## Interaction At the beginning, your program should read one integer $n$ ($1 <= n <= 250$) — the number of elements.In order to make a query of the first type, print "_1 $i$_" ($1 <= i <= n$). After this query, read one integer — the value of $a_i$.In order to make a query of the second type, print "_2 $k$_" ($2 <= k <= n$). Then in the same line print $k$ space-separated distinct integers — $i_1, i_2, \\dots, i_k$, ($1 <= i_j <= n$). After this query read $frac(k dot.op (k -1), 2)$ integers — $mid a_{i_c} -a_{i_d} mid$ for every $c < d$. These values will be given in random order.Once you know the answer, print "_3_". Then in the same line, print $n$ space-separated integers — $a_1, a_2, \\dots, a_n$ ($1 <= a_i <= 10^9$). Your program must terminate after this query.If for either of two first queries you get one number $-1$ as the answer, then it means that you made more queries than allowed, or made an invalid query. Your program should immediately terminate (for example, by calling _exit(0)_). You will receive "_Wrong Answer_". If you ignore this, you can get other verdicts since your program will continue to read from a closed stream.After printing a query do not forget to output end of line and flush the output. Otherwise, you will get _Wall time-limit exceeded_. To do this, use: _fflush(stdout)_ or _cout.flush()_ in C++; _System.out.flush()_ in Java; _stdout.flush()_ in Python.Precisely follow this format of interaction. [samples] ## Note In the first query of type $1$, we ask the value of $a_1$ and receive $1$ as the answer.In the second query of type $2$, we ask the value of $a_2$ and receive $2$ as the answer.In the query of type $2$, we ask all the possible differences between the elements of array with indexes $1$, $2$ and $3$. And we get array $4, 3, 1$ as the result. We know that the array contains values $| a_1 -a_2 |, | a_1 -a_3 |, | a_2 -a_3 |$. Since we already know that $| a_2 -a_1 | = 1$, one of the following is true: $| a_1 -a_3 | = 3$ and $| a_2 -a_3 | = 4$ or $| a_2 -a_3 | = 3$ and $| a_1 -a_3 | = 4$. The only case that is possible, taking into account the constraints of the problem, is when $| a_1 -a_3 | = 4$ and $| a_2 -a_3 | = 3$ with $a_3 = 5$. Since we know the values of all the elements of the array, we print them in the last query.
**Definitions** Let $(x, y) \in \mathbb{Z}^2$ be the starting coordinates. Let $s \in \{L, R, U, D\}^*$ be a string of moves of length $n = |s|$. **Constraints** 1. $1 \le x, y \le 100$ 2. $1 \le |s| \le 100$ **Objective** Compute the final position $(x', y')$ after applying each move in $s$ sequentially: - $L$: $(x, y) \mapsto (x - 1, y)$ - $R$: $(x, y) \mapsto (x + 1, y)$ - $U$: $(x, y) \mapsto (x, y + 1)$ - $D$: $(x, y) \mapsto (x, y - 1)$ Output $(x', y')$.
API Response (JSON)
{
  "problem": {
    "name": "C. Find the Array",
    "description": {
      "content": "_This is an interactive problem._ There is an array $a$ of length $n$, consisting of *distinct* integers. It is guaranteed that every element of the array is a positive integer less than or equal to ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10239C"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "_This is an interactive problem._\n\nThere is an array $a$ of length $n$, consisting of *distinct* integers. It is guaranteed that every element of the array is a positive integer less than or equal to ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $(x, y) \\in \\mathbb{Z}^2$ be the starting coordinates.  \nLet $s \\in \\{L, R, U, D\\}^*$ be a string of moves of length $n = |s|$.\n\n**Constraints**  \n1. $1 \\le x, y \\le 100$  \n2. $1...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments