B. Colored Blankets

Codeforces
IDCF10051B
Time1000ms
Memory512MB
Difficulty
English · Original
Formal · Original
Recently Polycarp has opened a blankets store and he faced with many challenges. He has got k blankets. A blanket has two sides, each of k blankets has at most one colored side. So either both sides are uncolored or one side is colored and the other one is not. If a side is colored, one of n possible colors is used. It is known that k is divisible by n. Polycarp wants to color all uncolored sides in such a way that: It is allowed to turn over blankets to determine that they are _identically colored_: for example, red-blue and blue-red blankets are _identically colored_. Blankets in different kits can be _identically colored_. The first line contains two integer numbers k and n (1 ≤ n ≤ k ≤ 1000) — number of blankets and colors. It is guaranteed that k is divisible by n. The second line contains a sequence of integers c1, c2, ..., ck (1 ≤ ci ≤ n or ci =  - 1), where ci stands for the color of the colored side of the i-th blanket or  - 1 if it is uncolored. If there is no solution for the problem, print "_No_" in the first line. Otherwise print a line containing "_Yes_" and k lines describing each blanket. The i-th line should contain a pair of colors (integers in the range 1, 2, ..., n) used for the i-th blanket. You may print colors in pairs in any order. If there are multiple solutions, print any of them. ## Input The first line contains two integer numbers k and n (1 ≤ n ≤ k ≤ 1000) — number of blankets and colors. It is guaranteed that k is divisible by n. The second line contains a sequence of integers c1, c2, ..., ck (1 ≤ ci ≤ n or ci =  - 1), where ci stands for the color of the colored side of the i-th blanket or  - 1 if it is uncolored. ## Output If there is no solution for the problem, print "_No_" in the first line. Otherwise print a line containing "_Yes_" and k lines describing each blanket. The i-th line should contain a pair of colors (integers in the range 1, 2, ..., n) used for the i-th blanket. You may print colors in pairs in any order.If there are multiple solutions, print any of them. [samples]
**Definitions** Let $ s \in \Sigma^* $ be the encrypted string, where $ \Sigma = \{a, b, \dots, z\} $ and $ 1 \leq |s| \leq 10^5 $. Let $ p \in \mathbb{Z} $ be the decryption parameter, where $ 1 \leq p \leq |s| $. **Constraints** 1. $ s $ consists only of lowercase English letters. 2. $ 1 \leq p \leq |s| $ **Objective** Decrypt $ s $ by performing a cyclic left shift of the string by $ p $ positions: $$ \text{original} = s[p:] + s[:p] $$
API Response (JSON)
{
  "problem": {
    "name": "B. Colored Blankets",
    "description": {
      "content": "Recently Polycarp has opened a blankets store and he faced with many challenges. He has got k blankets. A blanket has two sides, each of k blankets has at most one colored side. So either both sides ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10051B"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Recently Polycarp has opened a blankets store and he faced with many challenges.\n\nHe has got k blankets. A blanket has two sides, each of k blankets has at most one colored side. So either both sides ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ s \\in \\Sigma^* $ be the encrypted string, where $ \\Sigma = \\{a, b, \\dots, z\\} $ and $ 1 \\leq |s| \\leq 10^5 $.  \nLet $ p \\in \\mathbb{Z} $ be the decryption parameter, where $ 1 ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments