040. Valid Sudoku

Codeforces
IDCF10269040
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Sudoku is a popular number puzzle involving placing digits (1-9) in a 9 by 9 grid. A sudoku is considered _valid_ if all of the following are true: -All digits are integers from 1 to 9 -No number occurs in the same row twice -No number occurs in the same column twice -No number occurs in the same 3 by 3 box twice. Given a sudoku board, print whether or not it is valid. The input consists of nine lines, each containing nine space-separated integers ranging from 1 to 9. If the sudoku is valid, output VALID, otherwise output INVALID. ## Input The input consists of nine lines, each containing nine space-separated integers ranging from 1 to 9. ## Output If the sudoku is valid, output VALID, otherwise output INVALID. [samples]
**Definitions** Let $ G \in \{1, 2, \dots, 9\}^{9 \times 9} $ be a 9×9 grid representing the Sudoku board. **Constraints** 1. For all $ i, j \in \{1, \dots, 9\} $, $ 1 \le G[i][j] \le 9 $. 2. For each row $ i \in \{1, \dots, 9\} $, the elements $ G[i][1], G[i][2], \dots, G[i][9] $ are distinct. 3. For each column $ j \in \{1, \dots, 9\} $, the elements $ G[1][j], G[2][j], \dots, G[9][j] $ are distinct. 4. For each 3×3 box $ (b_r, b_c) \in \{0,1,2\} \times \{0,1,2\} $, the set $$ \{ G[3b_r + r][3b_c + c] \mid r, c \in \{1,2,3\} \} $$ contains distinct elements. **Objective** Output "VALID" if all constraints hold; otherwise, output "INVALID".
API Response (JSON)
{
  "problem": {
    "name": "040. Valid Sudoku",
    "description": {
      "content": "Sudoku is a popular number puzzle involving placing digits (1-9) in a 9 by 9 grid. A sudoku is considered _valid_ if all of the following are true: -All digits are integers from 1 to 9 -No number oc",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269040"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Sudoku is a popular number puzzle involving placing digits (1-9) in a 9 by 9 grid. A sudoku is considered _valid_ if all of the following are true:\n\n-All digits are integers from 1 to 9\n\n-No number oc...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ G \\in \\{1, 2, \\dots, 9\\}^{9 \\times 9} $ be a 9×9 grid representing the Sudoku board.\n\n**Constraints**  \n1. For all $ i, j \\in \\{1, \\dots, 9\\} $, $ 1 \\le G[i][j] \\le 9 $.  \n2. F...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments