For the city's evacuation grid, some intersections are marked as free "shuttle points" (zero-cost to move through) — Lamia needs the minimum-cost evacuation path considering these free shortcuts. Given an N×M grid, moving to an adjacent cell normally costs 1, but moving onto a cell marked 'T' (teleport-friendly) costs 0. Find the minimum cost path from top-left to bottom-right. Use a deque-based 0-1 BFS, not Dijkstra with a heap (unnecessary overhead here).
Input
Line1: N M. Next N lines: grid rows ('.','#' wall,'T').
Output
Minimum cost, or -1 if unreachable.
Constraints
1 ≤ N,M ≤ 500
Sample Input
2 2 . T # .
Sample Output
0
main.c
Loading editor…
Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.