[Java] 백준 [2178] 미로 탐색
import java.util.LinkedList; import java.util.Queue; public class Solution { // 미로 탐색 - BFS 2178번 // 최단 거리 탐색 BFS static int r = 4; static int c = 6; static int[][] arr = {{1, 0, 1, 1, 1, 1}, {1, 0, 1, 0, 1, 0}, {1, 0, 1, 0, 1, 1}, {1, 1, 1, 0, 1, 1}}; static boolean[][] visit = {}; static int[] dx = {0, 0, -1, 1}; static int[] dy = {-1, 1, 0, 0}; public static void bfs(int n, int m) { Queue q =..
2022. 12. 24.
[Java] 백준 [7570] 줄 세우기
import java.util.Arrays; public class Solution { // 줄 세우기 - DP 7570번 // 제일 앞 또는 제일 뒤로만 이동 가능 // 연속된 가장 긴 증가하는 부분 수열 이용 static int n = 7; static int[] arr = {3, 7, 5, 2, 6, 1, 4}; static int[] dp = {1, 1, 1, 1, 1, 1, 1}; public static void setLine() { int clisCnt = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { if (arr[i] == arr[j] + 1) { dp[i] = Math.max(dp[i], dp[j] + 1); } } } ..
2022. 12. 17.