题解 | #数据分类处理#

数据分类处理

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

    while True:
        I = (input().split())[1:]
        R = list(set(map(int, input().split()[1:])))
        R.sort()
        res = []
        for r in R:
            tmp = []
            cnt = 0
            for index,i in enumerate(I):
                if str(r) in i:
                    cnt+=1
                    tmp.extend([str(index),i])
            if cnt != 0:
                tmp.insert(0, str(cnt))
                tmp.insert(0, str(r))
                res.extend(tmp)
        print(str(len(res))+' '+' '.join(res))
except:
    pass
全部评论

相关推荐

流浪的神仙:无恶意,算法一般好像都得9硕才能干算法太卷啦
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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