#K59507. Library Catalog Management

    ID: 30879 Type: Default 1000ms 256MiB

Library Catalog Management

Library Catalog Management

You are given a series of queries to manage a library book catalog. There are two types of queries:

  • ADD: Add a new book to the catalog or update the details of an existing book. The query is given in the format: ADD book_id title author year.
  • GET: Retrieve the details of a book with a given book_id. The details include the title, author, and year separated by a single space. If the book is not found, output NOT FOUND.

The program should process all queries sequentially. For each GET query, output the corresponding book information on a new line.

Note: The expected time complexity for each query is \(O(1)\) on average when using an appropriate data structure (e.g. hash table).

inputFormat

The input is given from stdin and consists of multiple lines. The first line contains a single integer Q representing the number of queries. Each of the next Q lines contains a query in one of the following formats:

  • ADD book_id title author year
  • GET book_id

All tokens are separated by a single space.

outputFormat

For each GET query, output one line to stdout containing the book's title, author, and year separated by spaces. If the book does not exist in the catalog, output NOT FOUND.

## sample
6
ADD 1 MobyDick Melville 1851
ADD 2 Hamlet Shakespeare 1603
GET 1
GET 3
ADD 1 MobyDick Melville 1852
GET 1
MobyDick Melville 1851

NOT FOUND MobyDick Melville 1852

</p>