053. Tic-Tac-Toe

Codeforces
IDCF10269053
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Given a tic-tac-toe board, return if you can win the game in one move or not. The first line will be the side that you are on, X or O. The next three lines are the are the current board. If you can win print "Yes you can.", otherwise print "No you can't." ## Input The first line will be the side that you are on, X or O. The next three lines are the are the current board. ## Output If you can win print "Yes you can.", otherwise print "No you can't." [samples]
**Definitions** Let $ s \in \{X, O\} $ be the current player's symbol. Let $ B \in \{X, O, \cdot\}^{3 \times 3} $ be the tic-tac-toe board, where $ \cdot $ denotes an empty cell. **Constraints** - $ B $ contains exactly $ s $ and $ \cdot $ (opponent’s symbol may be present, but only $ s $ is to be placed in empty cells). - The board is in a valid intermediate state (no game-over condition already satisfied for either player). **Objective** Determine if there exists an empty cell $ (i, j) $ such that placing $ s $ at $ (i, j) $ results in $ s $ occupying an entire row, column, or diagonal. Formally, output "Yes you can." if $$ \exists (i,j) \in \{0,1,2\}^2 \text{ s.t. } B[i][j] = \cdot \text{ and } s \text{ wins after placing at } (i,j), $$ otherwise output "No you can't."
API Response (JSON)
{
  "problem": {
    "name": "053. Tic-Tac-Toe",
    "description": {
      "content": "Given a tic-tac-toe board, return if you can win the game in one move or not. The first line will be the side that you are on, X or O. The next three lines are the are the current board. If you can ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269053"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given a tic-tac-toe board, return if you can win the game in one move or not.\n\nThe first line will be the side that you are on, X or O. The next three lines are the are the current board.\n\nIf you can ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ s \\in \\{X, O\\} $ be the current player's symbol.  \nLet $ B \\in \\{X, O, \\cdot\\}^{3 \\times 3} $ be the tic-tac-toe board, where $ \\cdot $ denotes an empty cell.\n\n**Constraints** ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments