题解 | #数据分类处理#
数据分类处理
http://www.nowcoder.com/practice/9a763ed59c7243bd8ab706b2da52b7fd
a = input().split()
a_num = int(a.pop(0))
b = input().split()
b_num = int(b.pop(0))
b = [int(i) for i in set(b)]
b.sort()
b = [str(i) for i in b]
res=[]
for x in b:
cnt = 0
total = len(res)
for i in range(len(a)):
if x in a[i]:
cnt +=1
res.append(i)
res.append(a[i])
if cnt!=0:
res.insert(total,cnt)
res.insert(total,x)
total = len(res)
res.insert(0,total)
print(' '.join(str(i) for i in res))