题解 | #数据分类处理#

数据分类处理

https://www.nowcoder.com/practice/9a763ed59c7243bd8ab706b2da52b7fd

I = input().split()
R = input().split()
I_arr = I[1: int(I[0])+1]
R_arr = sorted(list(set([int(x) for x in R[1:int(R[0])+1]])))

out = []
for ri in R_arr:
    p = [[i,x] for i,x in enumerate(I_arr) if str(ri) in x]
    if len(p) >0:
        out = out + [str(ri),str(len(p))]+[str(element) for row in p for element in row]
print(len(out),' '.join(out))

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务