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. CF1153F Serval and Bonus Problem 【期望】

    题目链接:洛谷 作为一只沉迷数学多年的蒟蒻OIer,在推柿子和dp之间肯定要选推柿子的! 首先假设线段长度为1,最后答案乘上$l$即可. 对于$x$这个位置,被区间覆盖的概率是$2x(1-x)$(线段 ...

  2. 8月清北学堂培训 Day6

    今天是杨思祺老师的讲授~ 图论 双连通分量 在无向图中,如果无论删去哪条边都不能使得 u 和 v 不联通, 则称 u 和 v 边双连通: 在无向图中,如果无论删去哪个点(非 u 和 v)都不能使得 u ...

  3. cesium billboard跨域问题1

    群里小伙伴问道使用billboard加载图片时出现跨域问题,一般认为在服务器端设置 Access-Control-Allow-Origin: * 例如用tomcat发布图片服务,可以这样设置:http ...

  4. redhat7.4安装gitlab

    1.参考官方安装指南 https://about.gitlab.com/install/#centos-7 2.遇到的问题 2.1.启动postfix出错 错误内容 Job for postfix.s ...

  5. 基于OVS命令的VLAN实现

    利用mininet创建如下拓扑,要求支持OpenFlow 1.3协议,主机名.交换机名以及端口对应正确 直接在Open vSwitch下发流表,实现如下连通性要求 h1 -- h4互通 h2 -- h ...

  6. oracle last_value使用过程中的一个细节

    测试结果集:select role_id,update_date from user_info where role_id='6505007898843021313' 使用last_value求出当前 ...

  7. oracle查询历史执行语句

    SELECT * FROM v$sqlarea WHERE PARSING_SCHEMA_NAME='GAVIN' and SQL_TEXT LIKE '%delete%' ORDER BY LAST ...

  8. php判断两个数组是否相等

    php判断两个数组是否相等 一.总结 一句话总结: php判断两个数组是否相等可以直接上==或者===号 二.php 判断两个数组是否相等 转自或参考:php 判断两个数组是否相等https://ww ...

  9. 解析PHP的self关键字

    PHP群里有人询问self关键字的用法,答案是比较明显的:静态成员函数内不能用this调用非成员函数,但可以用self调用静态成员函数/变量/常量:其他成员函数可以用self调用静态成员函数以及非静态 ...

  10. Android 显示系统:SurfaceFlinger详解

    一.Android系统启动 Android设备从按下开机键到桌面显示画面,大致过程如下图流程: 开机显示桌面.从桌面点击 App 图标到 Activity显示在屏幕上的过程又是怎样的呢?下面介绍And ...