-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path14425.py
38 lines (29 loc) · 845 Bytes
/
14425.py
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
import sys
input = sys.stdin.readline
EOL = "EOL"
if __name__ == '__main__':
n, m = map(int, input().split())
root = dict()
for insert_str in range(n):
inp_str = input().rstrip()
current = root
for i in range(len(inp_str)):
if inp_str[i] not in current:
current[inp_str[i]] = dict()
current = current[inp_str[i]]
current[EOL] = True
cnt = 0
for check_str in range(m):
inp_str = input().rstrip()
current = root
is_not_exist = False
for i in range(len(inp_str)):
if inp_str[i] not in current:
is_not_exist = True
break
current = current[inp_str[i]]
if is_not_exist:
continue
if EOL in current:
cnt += 1
print(cnt)