문제
https://www.acmicpc.net/problem/1759
코드
def dfs(i,len):
if len == l:
vo=0
co=0
for j in range(l):
if result[j] in 'aeiou': vo += 1
else: co+=1
if vo>=1 and co>=2:
print("".join(result))
return
for m in range(i, c):
if check[m]==0:
result.append(array[m])
check[m]=1
dfs(m + 1,len+1)
check[m]=0
del result[-1]
l, c = map(int, input().split())
array = input().split()
array.sort()
check = [0 for i in range(c)]
result = []
dfs(0,0)
'문제풀이 > DFS & BFS' 카테고리의 다른 글
@[파이썬] [DFS] 백준 1012 유기농 배추 (0) | 2022.12.27 |
---|---|
@[파이썬] [BFS] 백준 2178 미로 탐색 (0) | 2022.12.26 |
[PyPy] [BFS] 백준 9019 DSLR (0) | 2022.05.26 |
[PyPy] [DFS] 백준 15684 사다리 조작 (0) | 2022.05.19 |
[파이썬] [DFS] 백준 14500 테트로미노 (0) | 2022.05.15 |