blob: cdca88718127a590635870ccb00343e01883e3b2 (
plain)
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
|
f = open('1.in', 'r')
o = open('1.out', 'w')
T = int(f.readline().strip())
for t in xrange(T):
(N, M) = map(int, f.readline().strip().split(' '))
pe = [f.readline().strip() for _n in range(N)]
pc = [f.readline().strip() for _m in range(M)]
res = 0
fs = {'' : {}}
for paths in (pe, pc):
for p in paths:
dirs = p.split('/')
cur = fs
for d in dirs:
try:
cur = cur[d]
except KeyError:
cur[d] = {}
cur = cur[d]
if paths == pc:
res += 1
s = "Case #%d: %d\n" % (t+1, res)
print s
#o.write(s)
|