#K69367. Library Database Management

    ID: 33071 Type: Default 1000ms 256MiB

Library Database Management

Library Database Management

This problem requires you to implement a simplified library database management system. The system must support the following operations:

  • Add Book: Store a new book with its details.
  • Search Books: Given a title query (case-insensitive substring matching), return all matching books. If no book matches, output No matching books found..
  • List Books: Given a genre, list all books in that genre sorted by year of publication (from oldest to newest). If no book is found, output No books found in this genre..

Each book has a unique identifier, a title, an author, a genre, and the year it was published. Additionally, if any formula is needed in your explanation, please use the LaTeX format, for example: $year_1 < year_2$.

inputFormat

The input is read from standard input (stdin) in the following format:

  1. An integer N indicating the number of books to add.
  2. Then N lines follow. Each line contains the details of a book in the format:
    book_id, Title, Author, Genre, Year
    Note that the fields are separated by a comma and a space.
  3. An integer Q indicating the number of queries.
  4. Then Q lines follow, each containing a query in one of the two formats:
    • SEARCH <title>: Search for books with titles containing the given substring (case-insensitive).
    • LIST <genre>: List the books belonging to the given genre (case-insensitive) sorted by year of publication (oldest first).

outputFormat

For each query, output the result on a new line to standard output (stdout):

  • If the query is SEARCH and matching books are found, output a list (in Python list/dictionary format) of matching book entries. If no books match, output exactly: No matching books found.
  • If the query is LIST and there are books in that genre, output a list of books sorted by year ascending. Otherwise, output exactly: No books found in this genre.

Each book entry in the list must be in the format: {'ID': book_id, 'Title': 'title', 'Author': 'author', 'Genre': 'genre', 'Year': year}.

## sample
2
1, To Kill a Mockingbird, Harper Lee, Fiction, 1960
2, 1984, George Orwell, Dystopia, 1949
1
SEARCH 1984
[{'ID': 2, 'Title': '1984', 'Author': 'George Orwell', 'Genre': 'Dystopia', 'Year': 1949}]

</p>