-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBAEKJOON_1181
More file actions
42 lines (34 loc) · 1.05 KB
/
BAEKJOON_1181
File metadata and controls
42 lines (34 loc) · 1.05 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
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw =new BufferedWriter(new OutputStreamWriter(System.out));
int N = Integer.parseInt(br.readLine());
String[] str = new String[N];
for(int i=0; i<N; i++){
str[i] = br.readLine();
}
Arrays.sort(str,new Comparator<String>(){
@Override
public int compare(String s1, String s2){
if(s1.length()==s2.length()){
return s1.compareTo(s2);
}else{
return s1.length()-s2.length();
}
}
});
bw.write(str[0]);
bw.newLine();
bw.flush();
for(int i=1; i<N; i++){
if(!str[i-1].equals(str[i])){
bw.write(str[i]);
bw.newLine();
bw.flush();
}
}
bw.close();
}
}