#K69342. Library Management System
Library Management System
Library Management System
You are given a simulation of a library management system. In this system, books are stored by genre and each genre is managed by a designated librarian. Each book has a unique ISBN, a title, an author, and belongs to a specific genre. The system supports the following operations:
- AG <genre> <librarian>: Add a new genre with its librarian.
- RG <genre>: Remove a genre and all corresponding books.
- AB <isbn> <title> <author> <genre>: Add a new book to a genre. (The title, author, and genre are strings with no spaces.)
- RB <isbn>: Remove a book by its ISBN.
- SB <isbn>: Search for a book by its ISBN and output details in the format: title author genre. If the book does not exist, output BOOK NOT FOUND.
- LBG <genre>: List all book titles in that genre separated by a space. If there are no books, output NO BOOKS.
- LBA <author>: List all book titles by that author separated by a space. If there are no books, output NO BOOKS.
- LG: List all genres (in order of addition) separated by a space. If there is no genre, output NO GENRES.
All operations are provided via standard input. Your task is to simulate the operations and produce outputs for the query operations (SB
, LBG
, LBA
, LG
).
Note: If any mathematical formulas are needed, express them in \(\LaTeX\) format. In this problem, no formulas are required.
inputFormat
The input begins with an integer T
indicating the number of operations. The following T
lines each contain one operation in one of the formats described above. All string tokens (except for the command itself) will contain no spaces.
Example:
17 AG Fiction Alice AG Science Bob AB 1234567890123 TheGreatGatsby Fitzgerald Fiction AB 9876543210123 ABriefHistoryofTime Hawking Science SB 1234567890123 SB 9999999999999 LBG Fiction LBG Science LBG Mystery LBA Hawking LBA UnknownAuthor LG RB 1234567890123 SB 1234567890123 RG Science LG SB 9876543210123
outputFormat
For each query operation (SB, LBG, LBA, LG), output the result on a new line as specified in the problem statement.
## sample17
AG Fiction Alice
AG Science Bob
AB 1234567890123 TheGreatGatsby Fitzgerald Fiction
AB 9876543210123 ABriefHistoryofTime Hawking Science
SB 1234567890123
SB 9999999999999
LBG Fiction
LBG Science
LBG Mystery
LBA Hawking
LBA UnknownAuthor
LG
RB 1234567890123
SB 1234567890123
RG Science
LG
SB 9876543210123
TheGreatGatsby Fitzgerald Fiction
BOOK NOT FOUND
TheGreatGatsby
ABriefHistoryofTime
NO BOOKS
ABriefHistoryofTime
NO BOOKS
Fiction Science
BOOK NOT FOUND
Fiction
BOOK NOT FOUND
</p>