题解 | #数据分类处理#

数据分类处理

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

I = input().split()
R = input().split()
Icount = int(I[0])
Rcount = int(R[0])
I.pop(0)
R.pop(0)
Rr = list(map(str, sorted(list(set(list(map(int, R)))))))
temp = []
result = []
countList = []
count = 0
for i in Rr:
    for j, v in enumerate(I):
        if i in v:
            temp.append(str(j))
            temp.append(v)
            count += 1
    if count != 0:
        temp.insert(0, str(count))
        temp.insert(0, i)
        count = 0
        result.append(temp)
        temp = []
num = 0
for n in result:
    num = num + int(n[1])
num = (num + len(result)) * 2
print(num, end=" ")
for s in result:
    print(" ".join(s), end=" ")

全部评论

相关推荐

03-29 19:11
门头沟学院 Java
wyp_davis:是可以这样的,不过只要交钱就是假的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务