-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ1181.java
More file actions
31 lines (28 loc) ยท 1.03 KB
/
Q1181.java
File metadata and controls
31 lines (28 loc) ยท 1.03 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
/**
* Date: 2018. 10. 5.
* Author: inhyuck | https://github.com/inhyuck
* Solution URL: https://github.com/inhyuck/algorithm
* Title: ๋จ์ด ์ ๋ ฌ
* description: ์ํ๋ฒณ ์๋ฌธ์๋ก ์ด๋ฃจ์ด์ง N๊ฐ์ ๋จ์ด๊ฐ ๋ค์ด์ค๋ฉด ์๋์ ๊ฐ์ ์กฐ๊ฑด์ ๋ฐ๋ผ ์ ๋ ฌํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค.
* ๊ธธ์ด๊ฐ ์งง์ ๊ฒ๋ถํฐ
* ๊ธธ์ด๊ฐ ๊ฐ์ผ๋ฉด ์ฌ์ ์์ผ๋ก
* Problem URL: https://www.acmicpc.net/problem/1181
*/
package io.inhyuck.sort;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Q1181 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
scanner.nextLine();
Set<String> words = new HashSet<>();
for (int i = 0; i < n; i++) {
words.add(scanner.nextLine());
}
words.stream().sorted(Comparator.comparing(String::length).thenComparing(Comparator.naturalOrder()))
.forEach(System.out::println);
}
}