-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution_1257.java
More file actions
35 lines (26 loc) · 840 Bytes
/
Solution_1257.java
File metadata and controls
35 lines (26 loc) · 840 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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
public class Solution_1257 {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(bf.readLine());
for(int tc = 1 ; tc<=T ; tc++) {
int k = Integer.parseInt(bf.readLine());
String str = bf.readLine();
HashSet<String> hs = new HashSet<String>();
//±æÀÌ : i
//jºÎÅÍ j+i±îÁö
for(int i=1;i<=str.length();i++) {
for(int j=0;j<=str.length()-i;j++) {
hs.add(str.substring(j, j+i));
}
}
Object[] s=hs.toArray();
Arrays.sort(s);
System.out.println("#"+tc+" "+s[k-1]);
}// end of tc
}
}