题解 | #数据分类处理#
数据分类处理
https://www.nowcoder.com/practice/9a763ed59c7243bd8ab706b2da52b7fd
import sys I = input().strip().split() NI = int(I[0]) I = [I[i] for i in range(1,len(I))] R = input().strip().split() NR = int(R[0]) R = [int(R[i]) for i in range(1,len(R))] R = sorted(list(set(R))) R = list(map(str,R)) output = [] for r in R: r_out = [] cnt = 0 for i in I: if r in i: r_out.append(cnt) r_out.append(i) cnt +=1 if len(r_out)!=0: r_out.insert(0, len(r_out)//2) r_out.insert(0, r) output += r_out output.insert(0,len(output)) for i in output: print(i,end=' ')