-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1759.java
More file actions
63 lines (54 loc) · 1.9 KB
/
1759.java
File metadata and controls
63 lines (54 loc) · 1.9 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import java.io.*;
import java.util.*;
public class Main{
public static int L;
public static int C;
public static String[] arr;
public static String[] result;
public static boolean[] visited;
public static StringBuilder sb;
public static void main(String[] args)throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
L = Integer.parseInt(st.nextToken());
C = Integer.parseInt(st.nextToken());
arr = br.readLine().split(" ");
Arrays.sort(arr);
result = new String[L];
visited = new boolean[C];
sb = new StringBuilder();
dfs(0, 0);
System.out.println(sb);
}
public static void dfs(int start, int depth){
// "(.*)a(.*)|(.*)i(.*)|(.*)e(.*)|(.*)o(.*)|(.*)u(.*)"
// String.valueOf(result).matches(".*[a,i,e,o,u].*")
if(depth == L ){
int a = 0; int b = 0; String res = "";
for (int i =0;i<L;i++){
res += result[i];
if (result[i].equals("a")||result[i].equals("i")||result[i].equals("e")||result[i].equals("o")||result[i].equals("u")){
a++; //자음수 카운트
}
else{
b++; //
}
}
if (a>=1 && b>=2){
sb.append(res).append('\n');
}
return;
}
for (int i = start; i<C;i++){
if(!visited[i]){
visited[i] = true;
result[depth] = arr[i];
// if(depth == L-1 && String.valueOf(result).matches("(.*)a(.*)|(.*)i(.*)|(.*)e(.*)|(.*)o(.*)|(.*)u(.*)")){
// dfs(depth + 1);
// }
dfs(i + 1,depth + 1);
visited[i] = false;
}
}
}
}