From a96703b574b74ad76b66d2d82f10d8917ad4f17f Mon Sep 17 00:00:00 2001 From: LiiNi-coder <97495437+LiiNi-coder@users.noreply.github.com> Date: Sat, 16 Aug 2025 23:44:30 +0900 Subject: [PATCH] =?UTF-8?q?[20250816]=20BOJ=20/=20G5=20/=20=EC=95=94?= =?UTF-8?q?=ED=98=B8=20=EB=A7=8C=EB=93=A4=EA=B8=B0=20/=20=EC=9D=B4?= =?UTF-8?q?=EC=9D=B8=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0 \353\247\214\353\223\244\352\270\260.md" | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 "LiiNi-coder/202508/16 BOJ \354\225\224\355\230\270 \353\247\214\353\223\244\352\270\260.md" diff --git "a/LiiNi-coder/202508/16 BOJ \354\225\224\355\230\270 \353\247\214\353\223\244\352\270\260.md" "b/LiiNi-coder/202508/16 BOJ \354\225\224\355\230\270 \353\247\214\353\223\244\352\270\260.md" new file mode 100644 index 00000000..ee0fa478 --- /dev/null +++ "b/LiiNi-coder/202508/16 BOJ \354\225\224\355\230\270 \353\247\214\353\223\244\352\270\260.md" @@ -0,0 +1,69 @@ +```java +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.StringTokenizer; + +//TIP 코드를 실행하려면 을(를) 누르거나 +// 에디터 여백에 있는 아이콘을 클릭하세요. +public class Main { + private static BufferedReader br; + private static int L; + private static int C; + private static char[] Arr; + private static char[] Combination; + private static StringBuilder answer; + private static HashSet mos = new HashSet<>(Set.of('a', 'e', 'i', 'o', 'u')); + public static void main(String[] args) throws IOException { + br = new BufferedReader(new InputStreamReader(System.in)); + String[] temp = br.readLine().split(" "); + L = Integer.parseInt(temp[0]); + C = Integer.parseInt(temp[1]); + Arr = new char[C]; + Combination = new char[L]; + StringTokenizer st = new StringTokenizer(br.readLine()); + for(int i = 0; i < C; i++) { + Arr[i] = st.nextToken().charAt(0); + } + Arrays.sort(Arr); + answer = new StringBuilder(); + dfs(0, 0); + System.out.println(answer.toString()); + br.close(); + } + + private static void dfs(int startIndex, int depth) { + if(depth == L){ + if(isFullfill()){ + answer.append(new String(Combination)).append("\n"); + } + return; + } + for(int i = startIndex; i < C; i++){ + Combination[depth] = Arr[i]; + dfs(i + 1, depth + 1); + } + } + + private static boolean isFullfill() { + int countJa = 0; + int countMo = 0; + for(char c : Combination){ + if(mos.contains(c)){ + countMo++; + }else{ + countJa++; + } + } + if(countJa < 2 || countMo < 1){ + return false; + } + return true; + } +} +```