-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBJ_1759.py
More file actions
35 lines (30 loc) · 749 Bytes
/
BJ_1759.py
File metadata and controls
35 lines (30 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
L, C = map(int,input().split())
arr1 = sorted(list(input().split()))
chk = [0]*C
word = []
vowel_chk = 0
else_chk = 0
def permu(n,idx):
global vowel_chk, else_chk
if n == L and vowel_chk >= 1 and else_chk >= 2:
ans = ''.join(word)
print(ans)
return
for i in range(idx,C):
if chk[i] == 1:
continue
if chk[i] == 0:
chk[i] = 1
if arr1[i] in 'aeiou':
vowel_chk += 1
else:
else_chk += 1
word.append(arr1[i])
permu(n+1,i+1)
if arr1[i] in 'aeiou':
vowel_chk -= 1
else:
else_chk -= 1
word.pop()
chk[i] = 0
permu(0,0)