-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolution_2007_패턴마디의길이_유승아.java
53 lines (42 loc) · 1.16 KB
/
Solution_2007_패턴마디의길이_유승아.java
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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.Character.Subset;
public class Solution_2007_ÆÐÅϸ¶µðÀDZæÀÌ_À¯½Â¾Æ {
static String word;
static boolean flag;
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++) {
String input = bf.readLine();
boolean[] check = new boolean[100];
word="";
flag = false;
for(int i=0;i<input.length();i++) {
char c = input.charAt(i);
if(!check[c]) {
check[c] = true;
word+=c;
} else {
flag = false;
solve(input.substring(word.length()));
if(!flag) word+=c;
}
if(flag) break;
}
System.out.println("#"+tc+" "+word.length());
}// end of tc
}
public static void solve(String str) {
int len = word.length();
if(str.length() < len ) {
flag = true;
return;
}
String comp = str.substring(0,len);
if(word.equals(str.substring(0, len)))
solve(str.substring(len));
else return;
}
}