题解 | #数据分类处理#

数据分类处理

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


a = input().split()
a_num = int(a.pop(0))
b = input().split()
b_num = int(b.pop(0))


b = [int(i) for i in set(b)]
b.sort()
b = [str(i) for i in b]


res=[]
for x in b:
    cnt = 0
    total = len(res)
    for i in range(len(a)):
        if x in a[i]:
            cnt +=1
            res.append(i)
            res.append(a[i])
    if cnt!=0:
        res.insert(total,cnt)
        res.insert(total,x)
    
total = len(res)
res.insert(0,total)

print(' '.join(str(i) for i in res))
    


    




全部评论

相关推荐

06-17 21:57
门头沟学院 Java
白友:噗嗤,我发现有些人事就爱发这些,明明已读不回就行了,就是要恶心人
点赞 评论 收藏
分享
zhiyog:哈哈哈哈哈哈哈哈哈哈哈哈哈
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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