본문 바로가기

Java/백준10

[Java] 백준 [1697] 숨바꼭질 import java.util.Arrays; import java.util.LinkedList; import java.util.Queue; public class Solution { // 숨바꼭질 - BFS 1697번 static int n = 5; static int m = 17; public static void bfs(int a, int b) { Queue q = new LinkedList(); int[] check = new int[100001]; // 0 ~ 17까지 만들자 boolean[] visit = new boolean[100001]; Arrays.fill(check, 0); // 전체 0으로 초기화 q.offer(n); //5 넣고 visit[n] = true; // 5 방문 while.. 2022. 12. 12.
[Java] 백준 [1303] 전쟁 - 전투 import java.util.ArrayList; public class Solution { // 전쟁 - 전투 - DFS 1303번 static int n = 5; static int m = 5; static char[][] arr = {{'W','B','W','W','W'}, {'W','W','W','W','W'}, {'B','B','B','B','B'}, {'B','B','B','W','W'}, {'W','W','W','W','W'}}; static boolean[][] visit = new boolean[5][5]; static int[] dy = {-1, 1, 0, 0}; static int[] dx = {0, 0, -1, 1}; static ArrayList wList = new ArrayLi.. 2022. 12. 10.
[Java] 백준 [11048] 이동하기 public class Solution { // 이동하기 - DP 11048번 static int n = 3; static int m = 4; static int[][] arr = {{1, 2, 3, 4}, {0, 0, 0, 5}, {9, 8, 7, 6}}; static int[] dy = {1, 1, 0}; static int[] dx = {0, 1, 1}; static int[][] dp = new int[n][m]; public static void dfs(int a, int b) { for (int i = 0; i n - 1 || nx > m - 1) { continue; } dp[ny][.. 2022. 12. 10.
[Java] 백준 [1026] 보물 import java.util.*; public class Solution { // 보물 - Greedy 1026번 public static int minVal(int n, int[] arrA, int[] arrB) { int[] arrTempA = arrA; Integer[] tempB = Arrays.stream(arrB).boxed().toArray(Integer[]::new); Arrays.sort(tempB, Collections.reverseOrder()); int[] arrTempB = Arrays.stream(tempB).mapToInt(Integer::intValue).toArray(); Arrays.sort(arrTempA); int numVal = 0; //for (int i = 0;.. 2022. 12. 10.