#C838. Library Management System

    ID: 52355 Type: Default 1000ms 256MiB

Library Management System

Library Management System

You are required to implement a library management system that maintains a collection of books and supports several operations. The system stores each book's title and author and keeps track of the lending status.

The system should support the following commands:

  • ADD <title> <author>: Add a book with the given title and author to the library. If the book already exists, update its author and mark it as available.
  • REMOVE <title>: Remove the book with the given title from the system. Output True if the removal is successful, otherwise False.
  • LEND <title> <member_name>: Lend the book to the member if it exists and is available. Output True if lending is successful, otherwise False.
  • RETURN <title>: Mark the book as returned. Output True if the return is successful, otherwise False.
  • AVAILABLE <title>: Check if the book is available (i.e. exists and is not lent out). Output True or False.
  • SEARCH <author>: Search and output the titles of all books by the given author, separated by commas. If none are found, output an empty line.

All commands are provided via stdin, and the expected output for commands that return values should be printed to stdout.

The final system should be case-sensitive and exactly print True or False when required.

inputFormat

The first line contains an integer n denoting the number of commands. The following n lines each contain a command in one of the following formats:

  • ADD <title> <author>
  • REMOVE <title>
  • LEND <title> <member_name>
  • RETURN <title>
  • AVAILABLE <title>
  • SEARCH <author>

Note: Titles and authors do not contain spaces; underscores (_) may be used instead.

outputFormat

For each command that requires an output (REMOVE, LEND, RETURN, AVAILABLE, SEARCH), output the corresponding result on a separate line. Boolean outputs must be exactly True or False. For the SEARCH command, output the list of book titles separated by commas; if no books match, output an empty line.

## sample
6
ADD 1984 George_Orwell
AVAILABLE 1984
LEND 1984 Alice
AVAILABLE 1984
RETURN 1984
AVAILABLE 1984
True

True False True True

</p>