-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1316.java
More file actions
63 lines (52 loc) · 1.06 KB
/
1316.java
File metadata and controls
63 lines (52 loc) · 1.06 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package algo;
import java.util.Arrays;
import java.util.Scanner;
class Task {
private final Scanner sc = new Scanner(System.in);
private String[] strs;
private int N;
private boolean[] answer = new boolean[26];
private int res;
private void input() {
N = sc.nextInt();
strs = new String[N];
res = N;
for(int i=0; i<N; i++) strs[i] = sc.next();
setAnswer();
}
private void process() {
for(int i=0; i<N; i++) {
char[] temp = strs[i].toCharArray();
char ch = temp[0];
answer[(int)ch-97] = true;
for(int j=1; j<temp.length; j++) {
if(temp[j] == ch) {
answer[(int)ch-97] = true;
} else {
if(answer[(int)temp[j]-97]) {
res--;
break;
} else {
answer[temp[j]-97] = true;
ch = temp[j];
}
}
}
setAnswer();
}
System.out.println(res);
}
private void setAnswer() {
for(int i=0; i<26; i++) answer[i] = false;
}
public void run() {
input();
process();
}
}
public class Main {
public static void main(String[] args) {
Task task = new Task();
task.run();
}
}