题解 | 生词篇章查询

生词篇章查询

https://www.nowcoder.com/practice/3790042b79114ae5bd9f6eccdaeadfcd

from collections import defaultdict
import sys

n, d = int(sys.stdin.readline()), defaultdict(set)
for i in range(1, n + 1):
    s = sys.stdin.readline().split()
    for x in s[1:]:
        d[x].add(i)
m = int(sys.stdin.readline())
for _ in range(m):
    w = sys.stdin.readline().strip()
    print(" ".join(map(str, sorted(list(d[w])))) if w in d else "")

全部评论

相关推荐

03-06 18:20
门头沟学院 Java
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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