Skip to content

Commit bed8fc1

Browse files
committed
[BOJ]#1759. 암호만들기/골드5/힌트
https://www.acmicpc.net/problem/1759
1 parent 3d01744 commit bed8fc1

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

Hongjoo/백준/암호만들기.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""
2+
https://www.acmicpc.net/problem/1759
3+
4+
4 6
5+
a t c i s w
6+
['a', 'c', 'i', 's', 't', 'w']
7+
- 문자 C 가지로 서로 다른 L개의 문자로 이뤄진 비번
8+
- 비번은 최소 1개의 모음 , 최소 2개의 자음
9+
- 정렬된 문자열
10+
- goal) 모든 경우의 수
11+
12+
# 1. 문자 정렬 + 모음 . 자음 나눠두기
13+
# 2. 중복 x 일반 조합 ? (Backtraking)
14+
# 중복x , 순서 x , (조합)
15+
16+
"""
17+
L , C = map(int,input().split())
18+
arr = sorted(list(input().split())) # 전체 정렬
19+
20+
# print(f"1 -{arr}")
21+
result = [""] * L
22+
# print(arr)
23+
# 전체 l 경우에서 c 개 조합
24+
def backtracking(c , l , level , idx) :
25+
if level == l :
26+
a = 0 ; b = 0
27+
# print(f"result {result}")
28+
for k in range(l) :
29+
if result[k] in [ "a" , "e" , "i" ,"o" ,"u"]:
30+
a +=1
31+
else :
32+
b += 1
33+
if a >= 1 and b >= 2 :
34+
print("".join(result))
35+
36+
return
37+
for s in range(idx , c) :
38+
39+
result[level] = arr[s]
40+
backtracking(c,l,level+1, s+1)
41+
42+
43+
44+
backtracking(C , L , 0,0)

0 commit comments

Comments
 (0)