From 7898e14fa748af2c9923e7b68f60aff7e2d48d62 Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Sat, 23 Aug 2025 12:37:00 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Create=2023=20BOJ=20=EC=A2=8B=EC=9D=80=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=EB=AC=B8=EC=9E=90=EC=97=B4=EC=9D=98=20?= =?UTF-8?q?=EA=B0=9C=EC=88=98.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\354\235\230 \352\260\234\354\210\230.md" | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 "0224LJH/202508/23 BOJ \354\242\213\354\235\200 \353\266\200\353\266\204 \353\254\270\354\236\220\354\227\264\354\235\230 \352\260\234\354\210\230.md" diff --git "a/0224LJH/202508/23 BOJ \354\242\213\354\235\200 \353\266\200\353\266\204 \353\254\270\354\236\220\354\227\264\354\235\230 \352\260\234\354\210\230.md" "b/0224LJH/202508/23 BOJ \354\242\213\354\235\200 \353\266\200\353\266\204 \353\254\270\354\236\220\354\227\264\354\235\230 \352\260\234\354\210\230.md" new file mode 100644 index 00000000..42b74158 --- /dev/null +++ "b/0224LJH/202508/23 BOJ \354\242\213\354\235\200 \353\266\200\353\266\204 \353\254\270\354\236\220\354\227\264\354\235\230 \352\260\234\354\210\230.md" @@ -0,0 +1,95 @@ +``` java +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.*; + + +public class Main { + + static int badLimit,len,ans; + static boolean[] isBad; + static char[] word; + + static class TrieNode{ + HashMap map = new HashMap<>(); + + public void dfs(int badCnt) { + if (badCnt > badLimit) { + return; + } + ans++; + + for (char c: map.keySet()) { + TrieNode child = map.get(c); + + if (isBad[c-'a']) child.dfs(badCnt+1); + else child.dfs(badCnt); + } + + + } + } + + static TrieNode root = new TrieNode(); + + + + + public static void main(String[] args) throws IOException { + init(); + process(); + print(); + } + + public static void init() throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + String rawWord = br.readLine(); + len = rawWord.length(); + word = new char[len]; + + for (int i = 0 ; i < len; i++) { + word[i] = rawWord.charAt(i); + } + + String[] rawBadGood = br.readLine().split(""); + isBad = new boolean[26]; + for (int i = 0; i < 26; i++) { + isBad[i] = rawBadGood[i].equals("0"); + } + + badLimit = Integer.parseInt(br.readLine()); + ans = -1; + } + + public static void process() { + for (int i = 0; i < len; i++) { + insert(i); + } + + root.dfs(0); + + + + } + + public static void insert(int from) { + TrieNode node =root; + for (int i = from; i < len; i++) { + char ch = word[i]; + node = node.map.computeIfAbsent(ch, c -> new TrieNode()); + } + } + + + + + + + + public static void print() { + System.out.println(ans); + } +} + +``` From b54a2761719cccf0e95238870689b0569c0d9aee Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Sat, 23 Aug 2025 12:37:51 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[20250823]=20BOJ=20/=20G1=20/=20=EC=A2=8B?= =?UTF-8?q?=EC=9D=80=20=EB=B6=80=EB=B6=84=20=EB=AC=B8=EC=9E=90=EC=97=B4?= =?UTF-8?q?=EC=9D=98=20=EA=B0=9C=EC=88=98=20/=20=EC=9D=B4=EC=A2=85?= =?UTF-8?q?=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 85cb87df518bdcfa51ef771168a7c6790d25275a Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Sat, 23 Aug 2025 12:38:39 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[20250823]=20BOJ=20/=20G1=20/=20=EC=A2=8B?= =?UTF-8?q?=EC=9D=80=20=EB=B6=80=EB=B6=84=20=EB=AC=B8=EC=9E=90=EC=97=B4?= =?UTF-8?q?=EC=9D=98=20=EA=B0=9C=EC=88=98=20/=20=EC=9D=B4=EC=A2=85?= =?UTF-8?q?=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...236\220\354\227\264\354\235\230 \352\260\234\354\210\230.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/0224LJH/202508/23 BOJ \354\242\213\354\235\200 \353\266\200\353\266\204 \353\254\270\354\236\220\354\227\264\354\235\230 \352\260\234\354\210\230.md" "b/0224LJH/202508/23 BOJ \354\242\213\354\235\200 \353\266\200\353\266\204 \353\254\270\354\236\220\354\227\264\354\235\230 \352\260\234\354\210\230.md" index 42b74158..b8b7f550 100644 --- "a/0224LJH/202508/23 BOJ \354\242\213\354\235\200 \353\266\200\353\266\204 \353\254\270\354\236\220\354\227\264\354\235\230 \352\260\234\354\210\230.md" +++ "b/0224LJH/202508/23 BOJ \354\242\213\354\235\200 \353\266\200\353\266\204 \353\254\270\354\236\220\354\227\264\354\235\230 \352\260\234\354\210\230.md" @@ -4,7 +4,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.*; - + public class Main { static int badLimit,len,ans;