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. reGeorg(不需要外网ip的代理)

    reGeorg _____ ______ __|___ |__ ______ _____ _____ ______ | | | ___|| ___| || ___|/ \| | | ___| | \ ...

  2. Linux设备驱动程序 之 软中断

    软中断保留给系统中对时间要求严格以及最重要的下半部使用:目前,只有两个子系统(网络和SCSI)直接使用软中断:此外,内核定时器和tasklet都是建立在软中断上的:在使用软中断之前,要先确定为什么不能 ...

  3. [转发]Android视频技术探索之旅:美团外卖商家端的实践

    美团技术团队 2019-09-12 20:02:11 背景 2013年美团外卖成立,至今一直迅猛发展.随着外卖业务量级与日俱增,单一的文字和图片已无法满足商家的需求,商家迫切需要更丰富的商品描述手段吸 ...

  4. docker常用指令

    1.查看docker信息 docker system df 2.删除镜像 docker rmi --删除镜像 docker image prune --删除虚悬镜像 3.守护态运行 docker ru ...

  5. Linux下使用 Nginx

    1. 下载Nginx 下载地址 下载完成后,上传到linux服务器,我上传到了 /opt文件夹下. 2. 安装Nginx前的准备 要想使用Nginx需要安装PCRE库和zlib库,否则直接安装Ngin ...

  6. Vue篇之vue 使用Jade模板写html

    // 安装jade包 npm install jade jade-loader --save-dev // 如果使用vue-cli构建项目,则不需要安装stylus相关的包,vue-cli默认已安装 ...

  7. 20190710记录:去掉中转图,直接以1280*1024进行反坐标计算,填补pbFinal。

    1.记录:去掉中转图,直接以1280*1024进行反坐标计算.pbFinal=1280*1024. // Imagejoint.cpp : 定义控制台应用程序的入口点. // #include &qu ...

  8. springboot整合redis(集群)

    一.加入maven依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactId> ...

  9. 12 Flutter仿京东商城项目 商品列表页面请求数据、封装Loading Widget、上拉分页加载更多

    ProductList.dart import 'package:flutter/material.dart'; import '../services/ScreenAdaper.dart'; imp ...

  10. 用python画函数图像

    import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 1, 50) # 从0到1,等分50分 y = 210*(x ...