题解 | #数据分类处理#

数据分类处理

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

I = input()
I = I.split()
R = input()
R = R.split()
I.remove(I[0])
R_len = int(R[0])
R.remove(R[0])
R = list(set(R))

for i in range(len(R)):
    R[i] = int(R[i])
R.sort()
for i in range(len(R)):
    R[i] = str(R[i])

s = []
ss = []
index = 0


for i in R:
    index = 0
    for j in range(len(I)):
        if i in I[j]:
            index += 1
    if index == 0:
        continue
    s.append(i)
    ss.append(str(index))
    for j in range(len(I)):
        if i in I[j]:
            s.append(str(j))
            ss.append(I[j])
            
        
merged_list = [item for pair in zip(s, ss) for item in pair]
merged_list.insert(0,str(len(merged_list)))

print(" ".join(merged_list))

全部评论

相关推荐

尊尼获获:闺蜜在哪?
点赞 评论 收藏
分享
斑驳不同:还为啥暴躁 假的不骂你骂谁啊
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务