基于大佬的代码,修改我自己能看懂的,哈哈 while True: try: lst = input().split() lst_str = lst[1:] num = input().split() num_str = num[1:] num_str = sorted(list(map(int, set(num_str)))) res = [] for x in num_str: count = 0 tmp_lst = [] out=[] for i in range(len(lst_str)): if str(x) in lst_str[i]: count += 1 tmp_lst.append(i) tmp_lst.append(lst_str[i]) else: continue if count !=0: out=[x]+[count]+tmp_lst res=res+out print(len(res),' '.join([str(x) for x in res])) except: break
点赞

相关推荐

牛客网
牛客企业服务