#P3879. Vocabulary Occurrence in Reading Passages
Vocabulary Occurrence in Reading Passages
Vocabulary Occurrence in Reading Passages
Given (N) reading passages, each consisting of several English words, your task is to determine in which passages specific query words appear. To save time looking up unfamiliar vocabulary, for each query word, output the 1-indexed passage numbers (in ascending order) where the word appears, or output 0 if it does not appear in any passage.
Input:
- The first line contains an integer (N).
- The next (N) lines each contain a passage of English text.
- Then, an integer (Q) is given on a new line, followed by (Q) lines each containing a query word.
Output:
- For each query, print a single line with the indices of all passages (separated by spaces) that include the query word, or print 0 if none do.
inputFormat
The input consists of:
1. A line with an integer (N) ((1 \leq N \leq 1000)), representing the number of passages.
2. (N) subsequent lines, each containing a passage with English words separated by spaces.
3. A line with an integer (Q) ((1 \leq Q \leq 1000)), representing the number of query words.
4. (Q) lines, each containing a single query word.
outputFormat
Output (Q) lines. Each line corresponds to a query and contains the 1-indexed numbers of the passages where the query word appears, separated by a single space. If a query word does not appear in any passage, output 0.
sample
3
apple banana
banana orange
kiwi apple orange
2
apple
orange
1 3
2 3
</p>