import numpy as np import sys # from collections import defaultdict data=[] while True: line = sys.stdin.readline().strip() if not line: break else: data.append(line) print(len(data)) #-------------------------------------------------------- from collections import defaultdict data = ["国家卫健委:全国新冠疫苗接种超8亿剂次", "超9亿剂次!1分钟看疫苗接种“中国速度”", "新冠病毒疫苗第二剂次接种“宁迟勿早”", "全国新冠疫苗接种剂次超7亿","全国新冠疫苗接种超5亿剂次", "广东新冠病毒疫苗接种突破4000万剂次 稳居全国第一", "[新闻直播间]国家卫健委 全国各地累计接种新冠疫苗超9亿剂次", "(一起苗苗苗) 长沙新冠病毒疫苗接种突破300万剂次", "全国累计报告接种新冠疫苗超3.80亿剂次", "超3亿剂次!全国新冠疫苗接种加速推进谁在努力"] query = ‘全国新冠疫苗接种剂次超9亿‘ res = [] d = defaultdict(int) for i in range(len(query)): d[query[i]]+=1 def name(q, l): count = min(len(q), len(l)) for i in range(min(len(q), len(l))): if q[i] == l[i]: count -= 1 else: break return count for i in range(len(data)): tmpd = d.copy() for j in data[i]: if tmpd[j]>0: tmpd[j] -= 1 res.append([sum(tmpd.values()),data[i],name(query,data[i])]) res.sort(key=lambda x:x[2]) res.sort(key=lambda x:x[0]) for i in range(5): print(res[i][1])