Submission #162937
Source Code Expand
using System; using System.Collections; class ABC007C { static int Main(string[] args) { string[] rc = Console.ReadLine().Split(); int R = int.Parse(rc[0]); int C = int.Parse(rc[1]); string[] sysx = Console.ReadLine().Split(); int sy = int.Parse(sysx[0]); int sx = int.Parse(sysx[1]); string[] gygx = Console.ReadLine().Split(); int gy = int.Parse(gygx[0]); int gx = int.Parse(gygx[1]); string[][] c = new string[R][]; for(int i = 0; i < R; i++){ string[] raw = Console.ReadLine().Split(); c[i] = raw; } string empty = "."; string wall = "#"; int[,] cost = new int[R, C]; for(int i = 0; i < R; i++){ for(int j = 0; j < C; j++){ if(c[i][j] == wall) cost[i, j] = -1; } } Queue qy = new Queue(); qy.Enqueue(sy); Queue qx = new Queue(); qx.Enqueue(sx); for(int next_cost = 1; next_cost <= (R - 2) * (C - 2); next_cost++){ for(int q = 0; q < qy.Count; q++){ int y = qy.Dequeue(); int x = qx.Dequeue(); if(cost[y - 1, x] == 0){ cost[y - 1, x] = next_cost; qy.Enqueue(y - 1); qx.Enqueue(x); } if(cost[y, x - 1] == 0){ cost[y, x - 1] = next_cost; qy.Enqueue(y); qx.Enqueue(x - 1); } if(cost[y + 1, x] == 0){ cost[y + 1, x] = next_cost; qy.Enqueue(y + 1); qx.Enqueue(x); } if(cost[y, x + 1] == 0){ cost[y, x + 1] = next_cost; qy.Enqueue(y); qx.Enqueue(x + 1); } } } int goal_cost = cost[gy, gx]; Console.WriteLine(goal_cost); return 0; } }
Submission Info
Submission Time | |
---|---|
Task | C - 幅優先探索 |
User | kutsutama |
Language | C# (Mono 2.10.8.1) |
Score | 0 |
Code Size | 1769 Byte |
Status | CE |
Compile Error
./Main.cs(39,13): error CS0266: Cannot implicitly convert type `object' to `int'. An explicit conversion exists (are you missing a cast?) ./Main.cs(40,13): error CS0266: Cannot implicitly convert type `object' to `int'. An explicit conversion exists (are you missing a cast?)