#C1483. Library Management System Simulation

    ID: 44522 Type: Default 1000ms 256MiB

Library Management System Simulation

Library Management System Simulation

This problem requires you to implement a simulation of a small-scale library management system. The system accepts a series of commands to manage books in a library. The commands are:

  • add <book_name>: Add a book to the library. If the book already exists (either available or borrowed), do nothing.
  • borrow <book_name>: Borrow a book from the library. If the book is not available, ignore this command.
  • return <book_name>: Return a borrowed book to the library. If the book was not borrowed, do nothing.
  • list: List all available books in the library in lexicographical order.

For sorting, the lexicographical order is used, i.e., if we denote two strings by \(a\) and \(b\), then \(a < b\) if in standard dictionary order. The simulation should output the result for each list command.

inputFormat

The input is given via standard input. The first line contains an integer \(n\) representing the number of commands. The next \(n\) lines each contain a command. A command is formatted as follows:

  • For commands add, borrow, and return, the line contains the command name followed by a space and then the book title. The book title may contain spaces.
  • The command list is given as a single word on a line.

outputFormat

For each list command encountered in the input, output a single line containing the titles of the available books in lexicographical order, separated by commas (","). If no books are available at that moment, output an empty line.

## sample
3
add Harry Potter
add The Hobbit
list
Harry Potter,The Hobbit

</p>