From 535a4246f89f909befa5537d5994e06f462c5631 Mon Sep 17 00:00:00 2001 From: JHLEE325 <82587652+JHLEE325@users.noreply.github.com> Date: Mon, 10 Nov 2025 08:30:38 +0900 Subject: [PATCH] =?UTF-8?q?[20251110]=20BOJ=20/=20G4=20/=20=EC=A2=8B?= =?UTF-8?q?=EC=9D=80=20=EC=88=98=EC=97=B4=20/=20=EC=9D=B4=EC=A4=80?= =?UTF-8?q?=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3\354\235\200 \354\210\230\354\227\264.md" | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 "JHLEE325/202511/10 BOJ G4 \354\242\213\354\235\200 \354\210\230\354\227\264.md" diff --git "a/JHLEE325/202511/10 BOJ G4 \354\242\213\354\235\200 \354\210\230\354\227\264.md" "b/JHLEE325/202511/10 BOJ G4 \354\242\213\354\235\200 \354\210\230\354\227\264.md" new file mode 100644 index 00000000..f22c2ce7 --- /dev/null +++ "b/JHLEE325/202511/10 BOJ G4 \354\242\213\354\235\200 \354\210\230\354\227\264.md" @@ -0,0 +1,41 @@ +```java +import java.io.*; +public class Main { + static int N; + static boolean found = false; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + N = Integer.parseInt(br.readLine().trim()); + dfs("", 0); + } + + static void dfs(String s, int depth) { + if (found) return; + if (depth == N) { + System.out.println(s); + found = true; + return; + } + for (int i = 1; i <= 3; i++) { + String ns = s + i; + if (goodString(ns)) { + dfs(ns, depth + 1); + } + if (found) return; + } + } + + static boolean goodString(String s) { + int len = s.length(); + for (int l = 1; l <= len / 2; l++) { + String a = s.substring(len - 2*l, len - l); + String b = s.substring(len - l, len); + if (a.equals(b)) { + return false; + } + } + return true; + } +} +```