[JAVA] 백준 알고리즘 7576 : 토마토 (BFS)
문제 소스 import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { static int n,m,x,y,_x,_y,result; static int map[][]; static boolean visit[][]; static int dx[] = {0, 1, 0, -1}; // 우, 하, 좌, 상 static int dy[] = {1, 0, -1, 0}; static Queue qx = new LinkedList(); static Queue qy = new LinkedList(); public static void bfs() { result = 0; while (!qx.isEmpty() &&..
[JAVA] 백준 알고리즘 2178 : 미로 탐색 (BFS)
빠른 경로 찾기 문제 소스 import java.util.*; public class Main { // (dx,dy) : 우(0,1), 하(1,0), 좌(0,-1), 상(-1,0) static int[] dx = {0,1,0,-1}; static int[] dy = {1,0,-1,0}; public static int n, m; public static int map[][]; // 미로 public static boolean visit[][]; // 방문 표시를 위한 배열 // 너비 우선 탐색 (BFS) public static void bfs(int x, int y) { // 시작 좌표 x,y Queue qx = new LinkedList(); Queue qy = new LinkedList(); qx...