static void Main() { var(h, w) = Read2(); var(ti, tj) = Read2(); var sv = (ti - 1, tj - 1); (ti, tj) = Read2(); var gv = (ti - 1, tj - 1); var c = Array.ConvertAll(new bool[h], _ => Console.ReadLine()); var dp = new DP2 <int>(h, w, MergeOp.Min(1 << 30)); dp[sv] = 0; dp.AddTransition(p => { if (c[p.i][p.j] == '#') { return; } var nv = p.Value + 1; p.Move(-1, 0).Merge(nv); p.Move(1, 0).Merge(nv); p.Move(0, -1).Merge(nv); p.Move(0, 1).Merge(nv); }); for (int k = 0; k < h * w; k++) { dp.Execute(0, h, 0, w); } Console.WriteLine(dp[gv]); }
protected ShapeV2(DP2 dp2) { _dp2 = dp2; }
public DrowingAdapterV2() { _dp1 = new DP2(); }
public RectangularV2(DP2 dp2) { this.dp2 = dp2; }
public P(int _i, int _j, DP2 <T> _dp) { i = _i; j = _j; dp = _dp; }