当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1497:Simple Library Management System

题目描述
After AC all the hardest problems in the world , the ACboy 8006 now has nothing to do . One day he goes to an old library to find a part-time job .It is also a big library which has N books and M users.The user's id is from 1 to M , and the book id is from 1 to N . According to the library rules , every user are only allowed to borrow 9 books .But what surprised him is that there is no computer in the library , and everything is just recorded in paper ! How terrible , I must be crazy after working some weeks , he thinks .So he wants to change the situation .

In the other hand , after 8006's fans know it , they all collect money and buy many computers for the library .

Besides the hardware , the library needs a management program . Though it is just a piece of cake for 8006 , the library turns to you , a excellent programer,for help .

What they need is just a simple library management program . It is just a console program , and have only three commands : Borrow the book , Return the book , Query the user .

1.The Borrow command has two parameters : The user id and the book id
The format is : "B ui bi" (1<=ui<=M , 1<=bi<=N)
The program must first check the book bi wether it's in the library . If it is not , just print "The book is not in the library now" in a line .
If it is , then check the user ui .
If the user has borrowed 9 books already, print "You are not allowed to borrow any more" .
Else let the user ui borrow the book , and print "Borrow success".

2.The Return command only has one parameter : The book id
The format is : "R bi" (1<=bi<=N)
The program must first check the book bi whether it's in the library . If it is , just print "The book is already in the library" . Otherwise , you can return the book , and print "Return success".

3.The Query command has one parameter : The user id
The format is : "Q ui" (1<=ui<=M)
If the number of books which the user ui has borrowed is 0 ,just print "Empty" , otherwise print the books' id which he borrows in increasing order in a line.Seperate two books with a blank.
输入解释
The input file contains a series of test cases . Please process to the end of file . The first line contains two integers M and N ( 1<= M <= 1000 , 1<=N<=100000),the second line contains a integer C means the number of commands(1<=C<=10000). Then it comes C lines . Each line is a command which is described above.You can assum all the books are in the library at the beginning of each cases.
输出解释
For each command , print the message which described above .
Please output a blank line after each test.
If you still have some questions , see the Sample .
输入样例
5 10
9
R 1
B 1 5
B 1 2
Q 1
Q 2
R 5
Q 1
R 2
Q 1
5 10
9
R 1
B 1 5
B 1 2
Q 1
Q 2
R 5
Q 1
R 2
Q 1
输出样例
The book is already in the library
Borrow success
Borrow success
2 5
Empty
Return success
2
Return success
Empty

The book is already in the library
Borrow success
Borrow success
2 5
Empty
Return success
2
Return success
Empty



Huge input, the function scanf() may work better than cin
来自杭电HDUOJ的附加信息
Author linle
Recommend LL

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-1497

最后修改于 2020-10-25T22:45:30+00:00 由爬虫自动更新

共提交 216

通过率 45.83%
时间上限 内存上限
4000/2000MS(Java/Others) 32768/32768K(Java/Others)