#K64982. Library Query System
Library Query System
Library Query System
You are given data about a library in which each book is identified by a unique integer ID and associated with a set of keywords. The task is to set up the library and process a number of queries. For each query, given a book ID and a keyword, you must determine whether the keyword exists in that book's data.
The input is provided via standard input (stdin
) and the output via standard output (stdout
). Note that the keywords are case-sensitive and consist of non-space characters.
You may assume that the number of books and keywords in each book are given explicitly. There are no special formulas in the problem, but if needed, you can refer to the set membership condition in \(\LaTeX\) as \(k \in S\), meaning keyword \(k\) is in the set \(S\).
inputFormat
The first line contains an integer (N) representing the number of books. The next (N) lines describe each book in the following format:
book_id K keyword1 keyword2 ... keywordK
where book_id
is an integer, K
is the number of keywords for that book, followed by (K) keywords.
After the book data, there is a line containing an integer (Q) representing the number of queries. Then (Q) lines follow, each containing a query in the format:
book_id keyword
For each query, output "Yes" if the keyword exists in the corresponding book, otherwise output "No".
outputFormat
For each query, print a single line containing either "Yes" or "No" depending on whether the keyword exists in the specified book.## sample
3
1 3 algorithm data structure
2 3 machine learning algorithm
3 2 data science
2
1 algorithm
2 machine
Yes
Yes
</p>