From eab8733e46feea5bdfa519415c483bc10d27553c Mon Sep 17 00:00:00 2001 From: siwon Date: Mon, 29 Dec 2025 22:41:42 +0900 Subject: [PATCH 1/3] =?UTF-8?q?solve:=20=EC=84=B8=20=EB=B2=88=20=EC=9D=B4?= =?UTF-8?q?=EB=82=B4=EC=97=90=20=EC=82=AC=EA=B3=BC=EB=A5=BC=20=EB=A8=B9?= =?UTF-8?q?=EC=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Mun.java" | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 "12\354\233\224/4\354\243\274\354\260\250/[BOJ] \354\204\270 \353\262\210 \354\235\264\353\202\264\354\227\220 \354\202\254\352\263\274\353\245\274 \353\250\271\354\236\220/Mun.java" diff --git "a/12\354\233\224/4\354\243\274\354\260\250/[BOJ] \354\204\270 \353\262\210 \354\235\264\353\202\264\354\227\220 \354\202\254\352\263\274\353\245\274 \353\250\271\354\236\220/Mun.java" "b/12\354\233\224/4\354\243\274\354\260\250/[BOJ] \354\204\270 \353\262\210 \354\235\264\353\202\264\354\227\220 \354\202\254\352\263\274\353\245\274 \353\250\271\354\236\220/Mun.java" new file mode 100644 index 0000000..ff6987f --- /dev/null +++ "b/12\354\233\224/4\354\243\274\354\260\250/[BOJ] \354\204\270 \353\262\210 \354\235\264\353\202\264\354\227\220 \354\202\254\352\263\274\353\245\274 \353\250\271\354\236\220/Mun.java" @@ -0,0 +1,53 @@ +import java.io.*; + +public class Mun { + static boolean[][] checked = new boolean[5][5]; + static int[][] board = new int[5][5]; + static boolean eatApple = false; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + for(int i=0;i<5;i++) { + String[] input = br.readLine().split(" "); + for(int j=0;j<5;j++) { + board[i][j] = Integer.parseInt(input[j]); + } + } + String[] loc = br.readLine().split(" "); + int r = Integer.parseInt(loc[0]); + int c = Integer.parseInt(loc[1]); + checked[r][c] = true; + findRoot(r, c, 0, 0); + System.out.print((eatApple) ? 1 : 0); + + } + static int[][] dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; + + private static void findRoot(int r, int c, int move, int appleCount) { + if(eatApple) { + return; + } + if(board[r][c] == 1) { + appleCount++; + } + if(move == 3) { + eatApple = appleCount >= 2; + return; + } + for(int[] d : dir) { + int nr = r + d[0]; + int nc = c + d[1]; + if(outOfRange(nr, nc) || checked[nr][nc] || board[nr][nc] == -1) { + continue; + } + checked[nr][nc] = true; + findRoot(nr, nc, move + 1, appleCount); + checked[nr][nc] = false; + } + + } + + private static boolean outOfRange(int nr, int nc) { + return (nr >= 5 || nr < 0 || nc >= 5 || nc < 0); + } +} \ No newline at end of file From c818d04b474a826509916ca92f051b7c257feb70 Mon Sep 17 00:00:00 2001 From: siwon Date: Mon, 29 Dec 2025 22:41:51 +0900 Subject: [PATCH 2/3] =?UTF-8?q?solve:=20=EC=8A=A4=ED=94=BC=EC=B9=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Mun.java" | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 "12\354\233\224/4\354\243\274\354\260\250/[BOJ] \354\212\244\355\224\274\354\271\264/Mun.java" diff --git "a/12\354\233\224/4\354\243\274\354\260\250/[BOJ] \354\212\244\355\224\274\354\271\264/Mun.java" "b/12\354\233\224/4\354\243\274\354\260\250/[BOJ] \354\212\244\355\224\274\354\271\264/Mun.java" new file mode 100644 index 0000000..94ddadb --- /dev/null +++ "b/12\354\233\224/4\354\243\274\354\260\250/[BOJ] \354\212\244\355\224\274\354\271\264/Mun.java" @@ -0,0 +1,40 @@ +import java.io.*; +import java.util.*; + +public class Mun { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + ArrayList[] line = new ArrayList[13]; + for(int i=1;i<=12;i++) { + line[i] = new ArrayList<>(); + } + for(int i=0;i<12;i++) { + String[] input = br.readLine().split(" "); + int x = Integer.parseInt(input[0]); + int y = Integer.parseInt(input[1]); + line[x].add(y); + line[y].add(x); + } + int Spika = -1; + for(int i=1;i<=12;i++) { + if(line[i].size() != 1) { + continue; + } + int sCandidate = line[i].get(0); + if(line[sCandidate].size() != 3) { + continue; + } + for(int star : line[sCandidate]) { + if(line[star].size() == 2) { + Spika = sCandidate; + break; + } + } + if(Spika > 0) { + break; + } + } + System.out.print(Spika); + } + +} \ No newline at end of file From 0431426ea07598660354c65278489ff84b286f29 Mon Sep 17 00:00:00 2001 From: siwon Date: Mon, 29 Dec 2025 22:42:01 +0900 Subject: [PATCH 3/3] =?UTF-8?q?solve:=20=EC=A3=BC=EB=82=9C=EC=9D=98=20?= =?UTF-8?q?=EB=82=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Mun.java" | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 "12\354\233\224/4\354\243\274\354\260\250/[BOJ] \354\243\274\353\202\234\354\235\230 \353\202\234/Mun.java" diff --git "a/12\354\233\224/4\354\243\274\354\260\250/[BOJ] \354\243\274\353\202\234\354\235\230 \353\202\234/Mun.java" "b/12\354\233\224/4\354\243\274\354\260\250/[BOJ] \354\243\274\353\202\234\354\235\230 \353\202\234/Mun.java" new file mode 100644 index 0000000..bdb35fe --- /dev/null +++ "b/12\354\233\224/4\354\243\274\354\260\250/[BOJ] \354\243\274\353\202\234\354\235\230 \353\202\234/Mun.java" @@ -0,0 +1,46 @@ +import java.io.*; +import java.util.*; + +public class Mun { + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + String[] input = br.readLine().split(" "); + int N = Integer.parseInt(input[0]); + int M = Integer.parseInt(input[1]); + String[] loc = br.readLine().split(" "); + int x1 = Integer.parseInt(loc[0]) - 1; + int y1 = Integer.parseInt(loc[1]) - 1; + int x2 = Integer.parseInt(loc[2]) - 1; + int y2 = Integer.parseInt(loc[3]) - 1; + char[][] map = new char[N][M]; + int[][] distance = new int[N][M]; + for(int i=0;i que = new LinkedList<>(); + que.add(new int[]{x1, y1, 1}); + while(que.size() > 0 ) { + int[] now = que.poll(); + for(int[] d : dir) { + int nx = now[0] + d[0]; + int ny = now[1] + d[1]; + if(nx < 0 || nx >= N || ny < 0 || ny >= M) + continue; + + int olddis = distance[nx][ny]; + int newdis = now[2] + ((map[nx][ny] == '1') ? 1 : 0); + if(olddis == 0 || olddis > newdis) { + distance[nx][ny] = newdis; + if(map[nx][ny] == '#') { + continue; + } + que.add(new int[]{nx, ny, newdis}); + } + } + } + System.out.print(distance[x2][y2]); + } +} \ No newline at end of file