728x90
https://www.acmicpc.net/problem/1759
조합 문제입니다.
문자를 정렬 후 조합시키면 조합된 문자열이 나오니 이들 중 조건에 맞는 것을 필터링하면 됩니다.
import sys
from itertools import combinations
input = sys.stdin.readline
def solution(L, C, chr):
# 조합
for comb in combinations(chr, L):
# 한 개의 모음과 두 개의 자음
m = 0
j = 0
for c in comb:
if c in 'aeiou':
m += 1
else:
j += 1
if m and j >= 2:
print(''.join(comb))
# 입력
L, C = map(int, input().strip().split())
chr = ''.join(sorted(input().strip().split()))
solution(L, C, chr)
728x90
'Coding Test > BaekJoon_Python' 카테고리의 다른 글
백준 1715 <카드 정렬하기> Python (0) | 2024.11.13 |
---|---|
백준 18405 <경쟁적 전염> Python (1) | 2024.11.12 |
백준 16398 <행성 연결> Python (0) | 2024.11.10 |
백준 17412 <도시 왕복하기 1> Python (1) | 2024.11.09 |
백준 1916 <최소비용 구하기> Python (0) | 2024.11.08 |