static void Main(string[] args) { var mapLenght = int.Parse(Console.ReadLine()); var mapHeight = int.Parse(Console.ReadLine()); _map = new Map(mapLenght, mapHeight); for (int i = 0; i < mapHeight; i++) { string row = Console.ReadLine(); _map.AddRow(i, row); } var bfsResolver = new BfsResolver(_map); var results = new List <int>(); int N = int.Parse(Console.ReadLine()); for (int i = 0; i < N; i++) { string[] inputs = Console.ReadLine().Split(' '); int X = int.Parse(inputs[0]); int Y = int.Parse(inputs[1]); var point = new Point(X, Y); results.Add(bfsResolver.GetResult(point)); } for (int i = 0; i < N; i++) { Console.WriteLine(results[i]); } }
public void NotTakeToolong() { var row = new string('O', 900); var map = new Map(900, 400); for (int i = 0; i < 400; i++) { map.AddRow(i, row); } var bfsResolver = new BfsResolver(map); var sw = new Stopwatch(); sw.Start(); bfsResolver.GetResult(new Point(43, 54)).ShouldBe(360000); sw.Stop(); sw.ElapsedMilliseconds.ShouldBeLessThan(1000); }