← 返回 meta 的题目列表AI Coding Maze: Add One-Way Cells (<' and '>') to Movement Rules
类型:online_judge
In a maze grid, introduce two one-way cell types:
>: it can only be entered from its left neighbor (i.e., you must move left-to-right into it);
<: it can only be entered from its right neighbor (i.e., you must move right-to-left into it).
Given an existing move(from, to) / canMove(r1,c1,r2,c2) method that currently checks only bounds and walls, modify it so that BFS/pathfinding obeys these one-way entry rules and passes unit tests.
Constraints: R,C <= 200, 4-directional moves.
Example: In S > E, the > is passable only if you approach it from the left.
Example
Input
1 3
S>E
Output
2