You are viewing a single comment's thread. Return to all comments →
from collections import defaultdict n, m = map(int, input().split()) word_to_indices = defaultdict(list) for i in range(n): word_to_indices[input()].append(i + 1) for _ in range(m): result = word_to_indices[input()] if len(result) == 0: print(-1) continue print(*result)
Seems like cookies are disabled on this browser, please enable them to open this website
DefaultDict Tutorial
You are viewing a single comment's thread. Return to all comments →