题解 | #数据分类处理#
数据分类处理
http://www.nowcoder.com/practice/9a763ed59c7243bd8ab706b2da52b7fd
import sys while True: try: I = input().strip().split()[1:] s_r = input().strip().split() #先转成数值排序 R = sorted(list(map(int, set(s_r[1:])))) #再换回字符串 R = list(map(str,R)) # print(I) # print(R) Res = [] for c in R: find = [] for index in range(len(I)): if c in I[index]: find.append(index) find.append(I[index]) if len(find) > 0: Res.append(c) Res.append(len(find) // 2) Res = Res + find Res.insert(0, len(Res)) print(" ".join(map(str,Res))) except: # print(sys.exc_info()) break