#K7261. Library Book Management

    ID: 33792 Type: Default 1000ms 256MiB

Library Book Management

Library Book Management

This problem involves managing a library's book borrowing system. You are given a library with a list of books, each characterized by a title and a status (either available or borrowed). You must perform an action on a specified book using a command: either to borrow it or return it.

The rules are as follows:

  • If the action is borrow and the chosen book is available, it should be marked as borrowed.
  • If the action is return and the chosen book is borrowed, it should be marked as available.
  • If the book does not exist in the library, print the message: \(\text{The book \"\" does not exist in the library.}\).
  • If the requested action cannot be performed because the book is already in the desired state, print the appropriate error message using the book title.

If the operation is successful, output the entire updated list of books maintaining the input order.

inputFormat

The input is provided via standard input (stdin) and consists of multiple lines:

  1. The first line contains an integer (n) representing the number of books in the library.
  2. The next (n) lines each contain a book record in the format: title,status (for example, 1984,available). The status is either "available" or "borrowed".
  3. The following line contains the action: either "borrow" or "return".
  4. The final line contains the title of the book on which the action is to be performed.

outputFormat

If the operation is successful, output the updated list of books (one book per line in the same order as provided) in the format: title,status. If the operation cannot be performed, output the corresponding error message exactly as specified.## sample

2
1984,available
Brave New World,borrowed
borrow
1984
1984,borrowed

Brave New World,borrowed

</p>