//层次优先遍历的思想,每次找到最近的位置进行外扩,如果外扩到目标节点说明找到了最短路径 import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int[] dx = new int[]{0, 0, 1, -1}; int[] dy = new int[]{1, -1, 0, 0}; while (in.hasNext()) { ...