Problem Description

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.

Input

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.

Output

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

Sample Input

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

Sample Output

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

Hint

Hint

纯粹的模拟题

#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int book[];
struct node
{
int x[];
int y;
} p[];
int main()
{
int n,m,b,u;
char a;
while(cin>>n>>m)
{
memset(book,,sizeof(book));
for(int i=; i<=n; i++)
p[i].y=;
int t;
cin>>t;
while(t--)
{
cin>>a;
if(a=='B')
{
cin>>u>>b;
if(book[b])
puts("The book is not in the library now");
else if(p[u].y>=)
puts("You are not allowed to borrow any more");
else
{
p[u].x[p[u].y++]=b;
book[b]=u;
puts("Borrow success");
}
}
else if(a=='R')
{
cin>>b;
if(book[b]==)
puts("The book is already in the library");
else
{
int poit;
u=book[b];
book[b]=;
for(int i=; i<p[u].y; i++)
{
if(p[u].x[i]==b)
{
poit=i;
break;
}
}
for(int i=poit; i<p[u].y-; i++)
p[u].x[i]=p[u].x[i+];
p[u].y--;
puts("Return success");
}
}
else if(a=='Q')
{
cin>>u;
if(p[u].y==)
puts("Empty");
else
{
int b[];
for(int i=; i<p[u].y; i++)
b[i]=p[u].x[i];
sort(b,b+p[u].y);
for(int i=; i<p[u].y; i++)
{
if(i==)
cout<<b[i];
else
cout<<" "<<b[i];
}
cout<<endl; }
}
}
cout<<endl;
}
return ;
}

Simple Library Management System HDU - 1497(图书管理系统)的更多相关文章

  1. 【HDOJ】1497 Simple Library Management System

    链表. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXM 1001 #def ...

  2. Library management system design requirements

    1)软件需求说明书 1. 引言 1.1 编写目的:本需求的编写是为了研究图书管理系统软件的开发途径和应用方法.同时它也是进行项目策划.概要设计和详细设计的基础,是维护人员进行内部维护,信息更新,验收和 ...

  3. 基于TXT文本的简单图书管理系统

    1 ////////////////////////////////////////////////////////////////////////////////////// //SqList.h ...

  4. 使用类和对象、方法、循环、List、泛型来实现简单的图书管理系统

    Book.java import java.util.List; import java.util.Scanner; public class Book { private String name; ...

  5. HR-人力资源管理系统(Human Resources Management System,HRMS)

    人力资源管理系统(Human Resources Management System,HRMS),是指组织或社会团体运用系统学理论方法,对企业的人力资源管理方方面面进行分析.规划.实施.调整,提高企业 ...

  6. Node操作MongoDB并与express结合实现图书管理系统

    Node操作MongoDB数据库 原文链接:http://www.xingxin.me/ Web应用离不开数据库的操作,我们将陆续了解Node操作MongoDB与MySQL这是两个具有代表性的数据库, ...

  7. C项目实践--图书管理系统(1)

    1.功能需求分析 图书管理系统主要用于对大量的图书信息,包括书名.作者.出版社.出版日期.ISBN(书号)等进行增.删.改.查以及保存等操作.同时也包括对用户的管理,用户包括管理员和普通用户两种权限, ...

  8. C项目实践--图书管理系统(2)

    前面在<<C项目实践-图书管理系统(1)>>中把系统中的三大功能模块中可能涉及到的常量,结构体及相关函数进行了声明定义,下来就来实现它们. 执行系统首先从登录到系统开始,所以首 ...

  9. 基于Android平台的图书管理系统的制作(2)

    上一篇讲解了制作图书管理系统的初衷与要求,和app首页的代码. 下面来介绍图书管理系统的服务对象:学生 学生类的设计: 个人信息:账号.密码.姓名.学号.邮箱.年龄. 借阅信息:借阅总数(不超过十本) ...

随机推荐

  1. P1968 美元汇率 怀疑智商超过海平面

    https://www.luogu.org/problemnew/show/P1968 也是一道贪心题,一些计算: 然而我却弄得很复杂: 既然我们要的是最后的最大值,那我们为什么要注意中间的细节呢: ...

  2. 微信小程序开发-踩坑

    异步请求处理 详情描述: 微信小程序的wx.request({})请求时异步处理,以下代码 wx.reuest({ url:"https://XXXA", method:" ...

  3. Ryu控制器安装部署和入门

    Ryu官网简介,原滋原味 Ryu is a component-based software defined networking framework. Ryu provides software c ...

  4. puppeteer学习笔记合集

    官方英文版API入口(如果你英文好的话):https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md. 汉化版API入口(网上有 ...

  5. linux提权方法(不断总结更新)

    目录 1.suid提权 2.rbash绕过 3.git提权 4.Linux Kernel 4.4.x (Ubuntu 16.04) - 'double-fdput()' bpf(BPF_PROG_LO ...

  6. SpringBoot2.0 Actuator 监控参数说明

    主要内容更 监控参数说明 Maven坐标 <dependency> <groupId>org.springframework.boot</groupId> < ...

  7. 怎样在VMware虚拟机中使用安装并设置Ubuntu系统

    1 2 3 4 5 6 7 分步阅读 Ubuntu 系统是一款优秀的.基于GNU/Linux 的平台的桌面系统. 当然,目前为止很多应用程序还完全不能允许运行在 Ubuntu 系统上,而且 Ubunt ...

  8. mac安装mysql数据库及配置环境变量

    mac安装mysql数据库及配置环境变量 mac安装mysql数据库及配置环境变量 原文文链接:https://blog.csdn.net/qq_36004521/article/details/80 ...

  9. linux上安装phpstudy

    摘要:安装:wget-chttp://lamp.phpstudy.net/phpstudy.bin chmod+xphpstudy.bin  #权限设置./phpstudy.bin#运行安装用时十到几 ...

  10. 001-多线程-JUC线程池-线程池架构-Executor、ExecutorService、ThreadPoolExecutor、Executors

    一.概述 1.1.线程池架构图 1. Executor 它是"执行者"接口,它是来执行任务的.准确的说,Executor提供了execute()接口来执行已提交的 Runnable ...