import java.util.*; public class Main { static int[] visit= new int[100001]; static int start; static int end; public static void bfs(int v) { Queue q = new LinkedList(); q.add(v); visit[v] = 1; while (!q.isEmpty()) { int temp = q.poll(); for (int i = 0; i < 3; i++) { int next; if (i == 0) { next = temp + 1; } else if (i == 1) { next = temp - 1; } else { next = temp * 2; } if (next == end) { Sys..
import java.util.*; public class Main { static int map[][]; static boolean visit[]; static int N, M; static int virus; public static void dfs(int v) { visit[v] = true; for(int i = 1; i
import java.util.*; class Location{ int x, y; public Location(int x, int y) { this.x = x; this.y = y; } } public class Main { static int map[][]; // 2차원 미로 배열 static int isVisit[][]; // 2차원 방문여부 배열 static int n,m; static int[] xArr = {-1,0,1,0}; static int[] yArr = {0,1,0,-1}; public static void bfs() { //BFS메소드 Queue q = new LinkedList(); q.add(new Location(1,1)); //큐에 시작점들을 추가 isVisit[1][1] = ..