#K51697. Library Book Management System
Library Book Management System
Library Book Management System
This problem simulates a library book management system. The system supports four types of operations:
- ADD <UID> <genre> <difficulty>: Add a book with unique identifier UID, belonging to a specific genre and having an integer difficulty rating.
- REMOVE <UID>: Remove the book with the specified UID from the system.
- COUNT_GENRE <genre>: Output the number of books currently in the specified genre.
- HARDEST_BOOK <genre>: Output the UID of the book with the highest difficulty in the specified genre. If there are multiple books with the same highest difficulty, the one which was added first is returned. If there are no books in that genre, output
None
.
All formulas in the problem statement (if any) are rendered using \(\LaTeX\)
representation. For example, the difficulty comparison can be understood as selecting the book with maximum \(d\) satisfying:
inputFormat
The input is read from stdin and is formatted as follows:
- The first line contains an integer n, the number of operations.
- The next n lines each contain a command in one of the following formats:
ADD <UID> <genre> <difficulty>
REMOVE <UID>
COUNT_GENRE <genre>
HARDEST_BOOK <genre>
outputFormat
For each query operation (COUNT_GENRE
and HARDEST_BOOK
), output the result to stdout, each on a new line. For HARDEST_BOOK
, if there is no book in the specified genre, output None
.
8
ADD 1 Fiction 3
ADD 2 Fiction 5
ADD 3 Mystery 7
COUNT_GENRE Fiction
HARDEST_BOOK Fiction
REMOVE 2
COUNT_GENRE Fiction
HARDEST_BOOK Fiction
2
2
1
1
</p>