Skip to content

Commit 4848673

Browse files
committed
112차 1번 문제풀이(참고)
1 parent 8e9335d commit 4848673

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import sys
2+
from collections import defaultdict
3+
4+
input = sys.stdin.readline
5+
6+
def bt(word, length):
7+
if length == len(word):
8+
print(''.join(word))
9+
return
10+
for a in alpha:
11+
# 해당 알파벳을 사용할 수 있다면
12+
if alpha[a]:
13+
alpha[a] -= 1
14+
bt(word + a, length)
15+
alpha[a] += 1
16+
17+
n = int(input())
18+
for _ in range(n):
19+
word = sorted(list(map(str, input().rstrip())))
20+
alpha = defaultdict(int)
21+
for w in word:
22+
alpha[w] += 1
23+
24+
bt('', len(word))

0 commit comments

Comments
 (0)