#K11046. Library Book Management System
Library Book Management System
Library Book Management System
You are given a library containing n books labeled from 1 to n. Initially, all books are available.
Your task is to implement a management system to process various library operations. The available operations are:
- BORROW x: Borrow the book with the identification number x if it is available.
- RETURN x: Return the book with the identification number x if it is currently borrowed.
- STATUS: Display the current status of the library. For each STATUS command, print two lines. The first line shows the available books (sorted in increasing order) and the second line shows the borrowed books (also sorted in increasing order). If no books are in a list, output
None
.
The system maintains the invariant described by the formula \(\text{status} = (\text{available},\, \text{borrowed})\) at any moment.
inputFormat
The first line of input contains two integers n and m (1 \(\leq n, m \leq 10^5\)), where n is the number of books in the library and m is the number of operations to be performed.
Each of the following m lines contains one of the following commands:
BORROW x
RETURN x
STATUS
outputFormat
For every STATUS
command encountered, print two lines:
- The first line lists the available book IDs in increasing order, separated by a space. Output
None
if there are no available books. - The second line lists the borrowed book IDs in increasing order, separated by a space. Output
None
if no book has been borrowed.
5 1
STATUS
1 2 3 4 5
None
</p>