-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1316.cpp
44 lines (36 loc) · 784 Bytes
/
1316.cpp
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
#include <stdio.h>
int N;
char W[100][101];
int P[26];
int answer;
int main()
{
answer = 0;
scanf("%d", &N);
for(int i = 0; i <= N-1; ++i) {
scanf("%s", W[i]);
}
for(int i = 0; i <= N-1; ++i) {
for(int j = 0; j <= 25; ++j) P[j] = -1;
int found = 0;
for(int j = 0; W[i][j]; ++j) {
if(P[W[i][j] - 'a'] == -1) {
P[W[i][j] - 'a'] = j;
}
else {
if(P[W[i][j] - 'a'] == j-1) {
P[W[i][j] - 'a'] = j;
}
else {
found = 1;
break;
}
}
}
if(!found) {
answer++;
}
}
printf("%d\n", answer);
return 0;
}