본문 바로가기

BFS4

[JAVA] 백준 2206 벽 부수고 이동하기 [BFS] 전체 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; public class baek { static int N, M, MIN = Integer.MAX_VALUE; static char arr[][]; static boolean chk = false; static int dy[] = { 1, -1, 0, 0 }; static int dx[] = { 0, 0, 1, -1 }; static boolean v[][][]; //stati.. 2020. 8. 26.
[JAVA] SWEA 1238 Contact [BFS] 전체 코드 import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class SWEA_1238_Contact { public static void main(String[] args) { int T = 10, N, start, x, y; Scanner sc = new Scanner(System.in); ArrayList[] arr; for(int test_case=1; test_case 2020. 8. 18.
[JAVA] SWEA 1226 미로1 [BFS, DFS] 전체 코드 import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class SWEA_1226_미로1 { static int[] dy = { 1, -1, 0, 0 }; //상, 하, 우, 좌 static int[] dx = { 0, 0, 1, -1 }; static int chk; //도달유무 체크값 static class Point{ // bfs 사용시 필요한 좌표 클래스 int y, x; Point(int y, int x){ this.y = y; this.x = x; } } public static void main(String[] args) { Scanner sc = new Scanner(System... 2020. 8. 17.
[JAVA] SWEA 7699 수지의 수지 맞는 여행 [BFS] 전체 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class SWEA_7699_수지의수지맞는여행 { static int R, C, T, MAX; static boolean[] v; static int[] dy = { 1, -1, 0, 0 }; // 상,하,우,좌 static int[] dx = { 0, 0, 1, -1 }; public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamR.. 2020. 8. 17.