From d1e4a5007636db77a4257273ea4cd7616951b5b3 Mon Sep 17 00:00:00 2001 From: Jinyeong Seol Date: Sat, 22 Nov 2025 23:47:33 +0900 Subject: [PATCH] =?UTF-8?q?[20251122]=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=84=A4=EC=A7=84=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0 \352\263\204\353\213\250.md\342\200\216" | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 "Seol-JY/202511/22 BOJ G5 \352\271\200\353\260\245\354\262\234\352\265\255\354\235\230 \352\263\204\353\213\250.md\342\200\216" diff --git "a/Seol-JY/202511/22 BOJ G5 \352\271\200\353\260\245\354\262\234\352\265\255\354\235\230 \352\263\204\353\213\250.md\342\200\216" "b/Seol-JY/202511/22 BOJ G5 \352\271\200\353\260\245\354\262\234\352\265\255\354\235\230 \352\263\204\353\213\250.md\342\200\216" new file mode 100644 index 00000000..f4aa3155 --- /dev/null +++ "b/Seol-JY/202511/22 BOJ G5 \352\271\200\353\260\245\354\262\234\352\265\255\354\235\230 \352\263\204\353\213\250.md\342\200\216" @@ -0,0 +1,45 @@ +```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[] dist = new int[N + 1]; + Arrays.fill(dist, -1); + + ArrayDeque queue = new ArrayDeque<>(); + queue.offer(0); + dist[0] = 0; + + while (!queue.isEmpty()) { + int cur = queue.poll(); + + if (dist[cur] >= K) continue; + + int next1 = cur + 1; + if (next1 <= N && dist[next1] == -1) { + dist[next1] = dist[cur] + 1; + queue.offer(next1); + } + + int next2 = cur + cur / 2; + if (next2 <= N && dist[next2] == -1) { + dist[next2] = dist[cur] + 1; + queue.offer(next2); + } + } + + if (dist[N] != -1 && dist[N] <= K) { + System.out.println("minigimbob"); + } else { + System.out.println("water"); + } + } +} +```