-
백준 1303 전쟁-전투 / JAVA
https://www.acmicpc.net/problem/1303 1303번: 전쟁 - 전투 첫째 줄에는 전쟁터의 가로 크기 N, 세로 크기 M(1 ≤ N, M ≤ 100)이 주어진다. 그 다음 두 번째 줄에서 M+1번째 줄에는 각각 (X, Y)에 있는 병사들의 옷색이 띄어쓰기 없이 주어진다. 모든 자리에는 www.acmicpc.net > 풀이(BFS) /* * 백준 1303 전쟁-전투 * #실버1 * #BFS * 23.05.25 */ public class boj_1303 { static int N,M; static int[] dx = {1,0,-1,0}; static int[] dy = {0,1,0,-1}; static char[][] map; static boolean[][] visited; sta..
PS/BOJ
2023. 5. 25.
-
백준 1926 그림 / JAVA
https://www.acmicpc.net/problem/1926 1926번: 그림 어떤 큰 도화지에 그림이 그려져 있을 때, 그 그림의 개수와, 그 그림 중 넓이가 가장 넓은 것의 넓이를 출력하여라. 단, 그림이라는 것은 1로 연결된 것을 한 그림이라고 정의하자. 가로나 세로 www.acmicpc.net > 풀이(BFS) /* * 백준 1926 그림 * #실버1 * #BFS */ public class boj_1926 { static int n,m; static int[] dx = {1, 0, -1, 0}; // 하 우 상 좌 static int[] dy = {0, 1, 0, -1}; // 하 우 상 좌 static int[][] arr; static int cnt = 0; static int maxA..
PS/BOJ
2023. 5. 24.
-
백준 4963 섬의개수 / JAVA
https://www.acmicpc.net/problem/4963 4963번: 섬의 개수 입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스의 첫째 줄에는 지도의 너비 w와 높이 h가 주어진다. w와 h는 50보다 작거나 같은 양의 정수이다. 둘째 줄부터 h개 줄에는 지도 www.acmicpc.net > 풀이(DFS) /* * 백준 4963 섬의개수 * #실버2 * #DFS * 23.05.17 */ public class boj_4963_DFS { static int[] dx = {-1,-1,-1,0,1,1,1,0}; static int[] dy = {-1,0,1,1,1,0,-1,-1}; static int[][] arr; static boolean[][] checked; static i..
PS/BOJ
2023. 5. 17.
-
백준 2178 미로탐색 / JAVA
https://www.acmicpc.net/problem/2178 2178번: 미로 탐색 첫째 줄에 두 정수 N, M(2 ≤ N, M ≤ 100)이 주어진다. 다음 N개의 줄에는 M개의 정수로 미로가 주어진다. 각각의 수들은 붙어서 입력으로 주어진다. www.acmicpc.net public class boj_2178_mazeSrch_BFS { static int[] dx = {-1, 0, 1, 0}; static int[] dy = {0, 1, 0, -1}; static int N,M; static int[][] arr; static boolean[][] visited; static class Node { int x, y; public Node(int x, int y) { this.x = x; this..
PS/BOJ
2023. 1. 31.