From dc1fffd4661cb35db04598ab02cf71d483d8bf5f Mon Sep 17 00:00:00 2001 From: wonjunYou Date: Sat, 5 Oct 2024 09:39:47 +0900 Subject: [PATCH] 2024-10-05 --- .../BOJ_1759.py" | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "wonjunYou/\353\260\261\355\212\270\353\236\230\355\202\271/BOJ_1759.py" diff --git "a/wonjunYou/\353\260\261\355\212\270\353\236\230\355\202\271/BOJ_1759.py" "b/wonjunYou/\353\260\261\355\212\270\353\236\230\355\202\271/BOJ_1759.py" new file mode 100644 index 0000000..af64c14 --- /dev/null +++ "b/wonjunYou/\353\260\261\355\212\270\353\236\230\355\202\271/BOJ_1759.py" @@ -0,0 +1,36 @@ +import sys + +input = sys.stdin.readline + +def dfs(idx, password): + if len(password) == l: + vowel_count = 0 + consonant_count = 0 + + for letter in password: + if letter in vowels: + vowel_count += 1 + + else: + consonant_count += 1 + + if vowel_count >= 1 and consonant_count >= 2: + print(password) + + return + + if idx >= len(characters): + return + + dfs(idx + 1, password + characters[idx]) + dfs(idx + 1, password) + +l, c = map(int, input().rstrip('\n').split()) +characters = list(input().rstrip('\n').split()) + +characters.sort() + +vowels = ['a', 'e', 'i', 'o', 'u'] +vowels = set(vowels) + +dfs(0, "")