-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbj1316.py
More file actions
40 lines (28 loc) · 790 Bytes
/
bj1316.py
File metadata and controls
40 lines (28 loc) · 790 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
36
37
38
39
40
#https://www.acmicpc.net/problem/1316
import sys
N = int(sys.stdin.readline())
cnt = 0
while N > 0:
word = sys.stdin.readline().rstrip('\n')
check = [True] * 27
is_group_word = 1
for i in range(len(word)):
if check[ord(word[i]) - ord('a')] == True:
check[ord(word[i]) - ord('a')] = False
elif check[ord(word[i]) - ord('a')] == False:
if word[i] != word[i-1]:
is_group_word = 0
break
if is_group_word: cnt += 1
N-= 1
print(cnt)
# sorted, key 를 사용한 2번째 방법
# import sys
# N = int(sys.stdin.readline())
# cnt = 0
# while N >0:
# word = sys.stdin.readline().rstrip('\n')
# if list(word) == sorted(word,key=word.find):
# cnt+=1
# N-=1
# print(cnt)