-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoj1181.java
More file actions
37 lines (34 loc) · 1 KB
/
Boj1181.java
File metadata and controls
37 lines (34 loc) · 1 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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
public class Boj1181 {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
String[] word = new String[N];
for(int i=0; i<N;i++) {
word[i] = br.readLine();
}
// System.out.println(Arrays.toString(word));
Arrays.sort(word, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
if(o1.length()==o2.length()) return o1.compareTo(o2);
else return o1.length()-o2.length();
}
});
// for(int i=0; i<N;i++) {
// System.out.println(word[i]);
// }
// System.out.println(Arrays.toString(word));
System.out.println(word[0]);
for(int i=1; i<N;i++) {
if(!word[i].equals(word[i-1])) {
System.out.println(word[i]);
}
}
}//main
}//class