B. Racoon Virus

Codeforces
IDCF10268B
Time2000ms
Memory512MB
Difficulty
English · Original
Formal · Original
In an alternate universe, a virus carried primarily by raccoons has spread worldwide. To develop a vaccine, scientists are studying its RNA makeup. In this universe, RNA (Racoon Nucleic Acid) is constructed rather differently. An $m$-length RNA strand can be represented by an array of $m$ nonnegative integers $A_i$. A substrand of a RNA strand is any nonempty contiguous subarray of this RNA strand. Two substrands are said to be _compatible_ if the sum of their elements are equal. The _infection index_ of a RNA strand is the maximum size of a set containing only its substrands, such that no two elements in the set are compatible. To help in the research of the virus, the Pandemic Research Committee (PRC) has teamed up with the National Overseer Institute on Pandemic Havocs (NOI PH). Together, they discovered that the virus is an $n$-length RNA strand with infection index $k$. They also discovered that all elements making up the virus strand never exceeded $10^9$. However, after these discoveries, they are running low on virus samples to research with. As a member of the final selection pool of interns working in the NOI PH, you realized this was the perfect opportunity to prove your worth! You decide to try and reconstruct the virus with what is known to make more samples. If you succeed, you may even be invited to intern in the International Overseer of Infections (IOI)! Do your best! Note that the information obtained on the virus may have also been miscalculated, and a RNA strand with its characteristics may be inconstructible. If this is the case, you must also say so. The first line of input contains $t$, the number of test cases. Then $t$ lines follow, each containing two space separated integers $n$ and $k$. For each given $n$ and $k$, output a single line containing In addition, if you outputted _POSSIBLE_, print a second line containing $n$ space-separated integers $A_1, A_2, \\dots, A_n$ denoting the elements of the length-$n$ RNA strand. If there are several answers, output any. *For all subtasks* $1 <= t <= 10000$ $1 <= n <= 1000$ $1 <= k <= 10^6$ The sum of $n^2$ across all test cases in a file is $<= 10^7$ *Subtask 1* (16 points): $n < 30$ *Subtask 2* (17 points): $n <= 50$ *Subtask 3* (15 points): $n <= 100$ *Subtask 4* (14 points): $n <= 200$ *Subtask 5* (15 points): $n <= 400$ *Subtask 6* (9 points): $n <= 750$ *Subtask 7* (14 points): No additional constraints. _Sample case $1$:_ We have $n = 1$. It is impossible to create a $1$-length RNA strand with infection index $k = 2$, so we output _IMPOSSIBLE_. _Sample case $2$:_ We have $n = 3$. One $3$-length RNA strand that has infection index $k = 4$ is _2 1 2_. An example set of four substrands in this strand are $[ 1 ]$, $[ 2 ]$, $[ 1, 2 ]$, and $[ 2, 1, 2 ]$. Note that $[ 2, 1 ]$ and $[ 1, 2 ]$ are compatible because their element sums are the same, and hence cannot both be in this set. $[ 2, 2 ]$ is not a substrand because it is not contiguous. Other solutions exist such as _1 1 2_, and you may output any. ## Input The first line of input contains $t$, the number of test cases. Then $t$ lines follow, each containing two space separated integers $n$ and $k$. ## Output For each given $n$ and $k$, output a single line containing "_POSSIBLE_" (without the quotes) if there exists a length-$n$ RNA strand with infection index $k$ where every element $A_i$ is a nonnegative integer between $0$ and $10^9$ (inclusive), and "_IMPOSSIBLE_" (without the quotes) if it does not exist. In addition, if you outputted _POSSIBLE_, print a second line containing $n$ space-separated integers $A_1, A_2, \\dots, A_n$ denoting the elements of the length-$n$ RNA strand.If there are several answers, output any. [samples] ## Scoring *For all subtasks*$1 <= t <= 10000$$1 <= n <= 1000$$1 <= k <= 10^6$The sum of $n^2$ across all test cases in a file is $<= 10^7$*Subtask 1* (16 points): $n < 30$*Subtask 2* (17 points): $n <= 50$*Subtask 3* (15 points): $n <= 100$*Subtask 4* (14 points): $n <= 200$*Subtask 5* (15 points): $n <= 400$*Subtask 6* (9 points): $n <= 750$*Subtask 7* (14 points): No additional constraints. ## Note _Sample case $1$:_ We have $n = 1$. It is impossible to create a $1$-length RNA strand with infection index $k = 2$, so we output _IMPOSSIBLE_._Sample case $2$:_ We have $n = 3$. One $3$-length RNA strand that has infection index $k = 4$ is _2 1 2_. An example set of four substrands in this strand are $[ 1 ]$, $[ 2 ]$, $[ 1, 2 ]$, and $[ 2, 1, 2 ]$. Note that $[ 2, 1 ]$ and $[ 1, 2 ]$ are compatible because their element sums are the same, and hence cannot both be in this set. $[ 2, 2 ]$ is not a substrand because it is not contiguous. Other solutions exist such as _1 1 2_, and you may output any.
**Definitions** Let $ r, c \in \mathbb{Z}^+ $ denote the dimensions of each acrylic sheet. Let $ S_1, S_2, S_3 \subseteq [r] \times [c] $ be the sets of painted cells on sheets 1, 2, and 3, respectively. Let $ U_i = ([r] \times [c]) \setminus S_i $ be the set of unpainted cells on sheet $ i $. A **region** on sheet $ i $ is a maximal connected component (4-directional) of $ U_i $. Let $ x_i $ be the maximum number of regions achievable in any valid partition of sheet $ i $ (i.e., the maximum number of connected components of unpainted cells over all possible painting patterns $ S_i $). Define: $$ S = \frac{8 \min(x_1, x_2, x_3) - 2 \max(x_1, x_2, x_3)}{rc - 3} $$ Beauty: $$ B = \max(0, \min(2, S)) $$ **Constraints** 1. $ t = 50 $, each test case has distinct $ (r, c) $. 2. For each $ (r, c) $, exactly one of the following holds: - $ r = 1 $ and $ c \geq 1 $, or - $ c = 1 $ and $ r \geq 1 $, or - $ r \geq 2 $ and $ c \geq 2 $. 3. Output format: - For each sheet: $ r $ lines of $ c $ characters (`.` for unpainted, `#` for painted). - After each sheet: one line containing `-`. - Total output: $ 3r + 3 $ lines per test case. **Objective** For each $ (r, c) $, choose $ S_1, S_2, S_3 $ to maximize $ B $.
API Response (JSON)
{
  "problem": {
    "name": "B. Racoon Virus",
    "description": {
      "content": "In an alternate universe, a virus carried primarily by raccoons has spread worldwide. To develop a vaccine, scientists are studying its RNA makeup. In this universe, RNA (Racoon Nucleic Acid) is cons",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 524288
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10268B"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "In an alternate universe, a virus carried primarily by raccoons has spread worldwide. To develop a vaccine, scientists are studying its RNA makeup.\n\nIn this universe, RNA (Racoon Nucleic Acid) is cons...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ r, c \\in \\mathbb{Z}^+ $ denote the dimensions of each acrylic sheet.  \nLet $ S_1, S_2, S_3 \\subseteq [r] \\times [c] $ be the sets of painted cells on sheets 1, 2, and 3, respec...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments