题解 | #数据分类处理#
数据分类处理
https://www.nowcoder.com/practice/9a763ed59c7243bd8ab706b2da52b7fd
I = input() I = I.split() R = input() R = R.split() I.remove(I[0]) R_len = int(R[0]) R.remove(R[0]) R = list(set(R)) for i in range(len(R)): R[i] = int(R[i]) R.sort() for i in range(len(R)): R[i] = str(R[i]) s = [] ss = [] index = 0 for i in R: index = 0 for j in range(len(I)): if i in I[j]: index += 1 if index == 0: continue s.append(i) ss.append(str(index)) for j in range(len(I)): if i in I[j]: s.append(str(j)) ss.append(I[j]) merged_list = [item for pair in zip(s, ss) for item in pair] merged_list.insert(0,str(len(merged_list))) print(" ".join(merged_list))