static void Main() { var(h, w) = Read2(); var sv = Read2() - new P(1, 1); var ev = Read2() - new P(1, 1); var s = Array.ConvertAll(new bool[h], _ => Console.ReadLine()); var r = GridShortestPath.UndirectedBfs(h, w, s, sv, ev); Console.WriteLine(r.GetByP(ev)); }
static bool Solve() { var(h, w) = Read2(); var s = GridShortestPath.ReadEnclosedGrid(ref h, ref w); var sv = GridShortestPath.FindChar(s, 's'); var ev = GridShortestPath.FindChar(s, 'g'); var r = GridShortestPath.UndirectedBfs(h, w, s, sv, ev); return(r.GetByP(ev) < int.MaxValue); }