F. Maze Design

Codeforces
IDCF10275F
Time2000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Alice has traveled back in time to Ancient Greece to meet one of her greatest idols, the famous inventor Daedulus. When Alice visits, Daedulus is analyzing a few maze passageways that he is considering including in his latest creation, the soon-to-be famous Labyrinth. Alice jumps at the opportunity to help Daedulus and needs to build a solver that determines if a given maze passageway is solvable or not. A maze passageway consists of $3$ rows that each have $n$ positions. Each position can either be blocked, which means that Alice cannot move through that position, or open, which means that Alice can move through that position. To solve a particular maze passageway, a person can move in any of the cardinal directions, as long as they don't move into a blocked position or go out of bounds of the passageway. Alice can start in any of the $3$ rows at the first position and can successfully solve the maze if she can reach the final position at any of the $3$ rows. Given a particular maze passageway that meets these criteria, you must output _Solvable!_ if Alice can solve the maze passageway and _Unsolvable!_ otherwise. The first line will consist of a single integer $n$ ($2 <= n <= 10^4$), which gives the number of positions per row. The next $3$ lines consist of a string, $s$, with $n$ characters that are either _0_ or _1_, representing a row of the maze passage way. If $s_i =$ _0_, then the $i$th position in that row is open, and if $s_i =$ _1_, then the $i$th position in that row is blocked. Output _Solvable!_ if the maze passageway is solvable and _Unsolvable!_ otherwise. ## Input The first line will consist of a single integer $n$ ($2 <= n <= 10^4$), which gives the number of positions per row. The next $3$ lines consist of a string, $s$, with $n$ characters that are either _0_ or _1_, representing a row of the maze passage way. If $s_i =$ _0_, then the $i$th position in that row is open, and if $s_i =$ _1_, then the $i$th position in that row is blocked. ## Output Output _Solvable!_ if the maze passageway is solvable and _Unsolvable!_ otherwise. [samples]
**Definitions** Let $ n \in \mathbb{Z} $ with $ 2 \leq n \leq 10^4 $. Let $ M = (r_1, r_2, r_3) $ be a $ 3 \times n $ binary matrix, where $ r_i \in \{0,1\}^n $ represents row $ i $, and $ r_{i,j} = 0 $ denotes an open cell, $ r_{i,j} = 1 $ denotes a blocked cell. **Constraints** 1. $ r_{i,j} \in \{0,1\} $ for all $ i \in \{1,2,3\} $, $ j \in \{1,\dots,n\} $. 2. Movement is allowed in cardinal directions (up, down, left, right) between adjacent open cells. 3. Start: any cell $ (i,1) $ with $ r_{i,1} = 0 $, $ i \in \{1,2,3\} $. 4. Goal: reach any cell $ (i,n) $ with $ r_{i,n} = 0 $, $ i \in \{1,2,3\} $. **Objective** Determine whether there exists a path from any starting cell $ (i,1) $ with $ r_{i,1} = 0 $ to any goal cell $ (j,n) $ with $ r_{j,n} = 0 $, using only moves between adjacent open cells. Output "Solvable!" if such a path exists; otherwise, output "Unsolvable!".
API Response (JSON)
{
  "problem": {
    "name": "F. Maze Design",
    "description": {
      "content": "Alice has traveled back in time to Ancient Greece to meet one of her greatest idols, the famous inventor Daedulus. When Alice visits, Daedulus is analyzing a few maze passageways that he is considerin",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10275F"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Alice has traveled back in time to Ancient Greece to meet one of her greatest idols, the famous inventor Daedulus. When Alice visits, Daedulus is analyzing a few maze passageways that he is considerin...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z} $ with $ 2 \\leq n \\leq 10^4 $.  \nLet $ M = (r_1, r_2, r_3) $ be a $ 3 \\times n $ binary matrix, where $ r_i \\in \\{0,1\\}^n $ represents row $ i $, and $ r_{i,j}...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments