题解 | #数据分类处理#
数据分类处理
http://www.nowcoder.com/practice/9a763ed59c7243bd8ab706b2da52b7fd
数据处理还是比较easy
while True: try: l = list(map(int, input().split())) r = list(map(int, input().split())) rr = list(set(r[1:])) rr.sort() ll_list = [] pp_list = [] for i in rr: res_list = [] for n, x in enumerate(l[1:]): if str(i) in str(x): res_list.append({str(x):n}) if res_list: ll_list.append(i) pp_list.append(res_list) zz_list = [] for ni, ii in enumerate(pp_list): zz_list.append(ll_list[ni]) zz_list.append(len(ii)) for i in ii: i = list(i.items())[0] zz_list.append(i[1]) zz_list.append(i[0]) zz_list.insert(0, len(zz_list)) zz_list = list(map(str, zz_list)) print(' '.join(zz_list)) except EOFError: break # 15,123,456,786,453,46,7,5,3,665,453456,745,456,786,453,123 # 5,6,3,6,3,0