Lang:Java
Edit12345678910111213141516171819202122232425262728293031import java.util.LinkedList;import java.util.Scanner;public class Main{public static void main(String args[]){Scanner scan = new Scanner(System.in);int n = scan.nextInt() , m = scan.nextInt();char map[][] = new char[n][m];int sx = -1 , sy = -1;for (int i = 0 ; i < n ; i++){String s = scan.next();map[i] = s.toCharArray();for (int j = 0 ; j < m ; j++)if (map[i][j] == 'H'){sx = i;sy = j;}}int dis[][] = new int[n][m];for (int i = 0 ; i < n ; i++)for (int j = 0 ; j < m ; j++)dis[i][j] = 10001;dis[sx][sy] = 0;LinkedList<Integer> bfs = new LinkedList<Integer>();