From 176cc987ccfe1058271c5fe37e6cc33582ec03ff Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Tue, 9 Dec 2025 20:25:25 +0900 Subject: [PATCH] =?UTF-8?q?[20251209]=20BOJ=20/=20G5=20/=20=EA=B9=80?= =?UTF-8?q?=EB=B0=A5=EC=B2=9C=EA=B5=AD=EC=9D=98=20=EA=B3=84=EB=8B=A8=20/?= =?UTF-8?q?=20=EC=9D=B4=EA=B0=95=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5\354\235\230 \352\263\204\353\213\250.md" | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 "lkhyun/202512/09 BOJ G5 \352\271\200\353\260\245\354\262\234\352\265\255\354\235\230 \352\263\204\353\213\250.md" diff --git "a/lkhyun/202512/09 BOJ G5 \352\271\200\353\260\245\354\262\234\352\265\255\354\235\230 \352\263\204\353\213\250.md" "b/lkhyun/202512/09 BOJ G5 \352\271\200\353\260\245\354\262\234\352\265\255\354\235\230 \352\263\204\353\213\250.md" new file mode 100644 index 00000000..fa260261 --- /dev/null +++ "b/lkhyun/202512/09 BOJ G5 \352\271\200\353\260\245\354\262\234\352\265\255\354\235\230 \352\263\204\353\213\250.md" @@ -0,0 +1,54 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int n = Integer.parseInt(st.nextToken()); + int k = Integer.parseInt(st.nextToken()); + + int minMoves = bfs(n); + + if (minMoves <= k) { + System.out.println("minigimbob"); + } else { + System.out.println("water"); + } + } + + static int bfs(int n) { + if (n == 0) return 0; + + Queue queue = new LinkedList<>(); + boolean[] visited = new boolean[n + 1]; + + queue.offer(new int[]{0, 0}); + visited[0] = true; + + while (!queue.isEmpty()) { + int[] cur = queue.poll(); + int pos = cur[0]; + int moves = cur[1]; + + int next1 = pos + 1; + if (next1 == n) return moves + 1; + if (next1 < n && !visited[next1]) { + visited[next1] = true; + queue.offer(new int[]{next1, moves + 1}); + } + + int next2 = pos + pos / 2; + if (next2 == n) return moves + 1; + if (next2 < n && !visited[next2]) { + visited[next2] = true; + queue.offer(new int[]{next2, moves + 1}); + } + } + + return Integer.MAX_VALUE; + } +} +```