题解 | #数据分类处理#

数据分类处理

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=' ')

全部评论

相关推荐

今天刚通知oc
跑不快的yyyf:接好运
点赞 评论 收藏
分享
08-06 08:33
四川大学 Java
OPPO官方内推:卧槽!!!啥破公司啊!!!
投递OPPO等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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