题解 | #数据分类处理#
数据分类处理
https://www.nowcoder.com/practice/9a763ed59c7243bd8ab706b2da52b7fd
while True: try: ls=input().split(' ')[1:] s=' '.join(ls) rs=input().split(' ')[1:] rs=list(map(int,set(rs))) rs.sort() rs=list(map(str,rs)) li=[] outcount=0 for i in rs: if i not in s: continue suli=[] suli.append(i) j,elecount=0,0 for ss in ls: if i in ss: suli.append(str(j)) suli.append(ss) elecount+=1 j+=1 suli.insert(1,str(elecount)) li.append(' '.join(suli)) outcount+=(elecount+1)*2 li.insert(0,str(outcount)) print(' '.join(li)) except: break