1022. Digital Library (30)

时间限制
1000 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit number as its ID. Given any query from a reader, you are supposed to output the resulting books, sorted in increasing order of their ID's.

Input Specification:

Each input file contains one test case. For each case, the first line contains a positive integer N (<=10000) which is the total number of books. Then N blocks follow, each contains the information of a book in 6 lines:

  • Line #1: the 7-digit ID number;
  • Line #2: the book title -- a string of no more than 80 characters;
  • Line #3: the author -- a string of no more than 80 characters;
  • Line #4: the key words -- each word is a string of no more than 10 characters without any white space, and the keywords are separated by exactly one space;
  • Line #5: the publisher -- a string of no more than 80 characters;
  • Line #6: the published year -- a 4-digit number which is in the range [1000, 3000].

It is assumed that each book belongs to one author only, and contains no more than 5 key words; there are no more than 1000 distinct key words in total; and there are no more than 1000 distinct publishers.

After the book information, there is a line containing a positive integer M (<=1000) which is the number of user's search queries. Then M lines follow, each in one of the formats shown below:

  • 1: a book title
  • 2: name of an author
  • 3: a key word
  • 4: name of a publisher
  • 5: a 4-digit number representing the year

Output Specification:

For each query, first print the original query in a line, then output the resulting book ID's in increasing order, each occupying a line. If no book is found, print "Not Found" instead.

Sample Input:

3
1111111
The Testing Book
Yue Chen
test code debug sort keywords
ZUCS Print
2011
3333333
Another Testing Book
Yue Chen
test code sort keywords
ZUCS Print2
2012
2222222
The Testing Book
CYLL
keywords debug book
ZUCS Print2
2011
6
1: The Testing Book
2: Yue Chen
3: keywords
4: ZUCS Print
5: 2011
3: blablabla

Sample Output:

1: The Testing Book
1111111
2222222
2: Yue Chen
1111111
3333333
3: keywords
1111111
2222222
3333333
4: ZUCS Print
1111111
5: 2011
1111111
2222222
3: blablabla
题意:根据给定的信息,查找该信息出自哪本书
思路:这题主要是一个输入问题,信息查找只要字符串进行比较即可。
AC代码:
#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<set>
#include<queue>
#include<map>
using namespace std;
#define INF 0x3f3f3f
#define N_MAX 10000+5
typedef long long ll;
struct book{
string id, title,auther,publisher,publish_year;
vector<string>key;
bool operator < (const book&b) {
return id < b.id;
}
};
int n;
vector<book>vec;
int main() {
while (scanf("%d",&n)!=EOF) {
getchar();
for (int i = ; i < n;i++) {
book b;
getline(cin, b.id);
getline(cin, b.title);
getline(cin, b.auther);
do {
string tmp; cin >> tmp;
b.key.push_back(tmp);
} while (getchar()!='\n');
getline(cin, b.publisher);
getline(cin, b.publish_year);
vec.push_back(b);
}
sort(vec.begin(),vec.end());
int m; cin >> m;
while(m--) {
vector<book>res;
int cs; string s;
scanf("%d: ", &cs);
getline(cin,s); for (int i = ; i < vec.size();i++) {
if (s == vec[i].auther||s == vec[i].id||s==vec[i].publisher||s==vec[i].publish_year||s==vec[i].title) { res.push_back(vec[i]);continue; }
else {
for (int j = ; j < vec[i].key.size(); j++) {
if (s == vec[i].key[j]) {
res.push_back(vec[i]); break;
}
}
}
}
printf("%d: %s\n", cs, s.c_str());
if (res.size()) {
for (int i = ; i < res.size(); i++) {
cout << res[i].id << endl;
}
}
else puts("Not Found");
}
}
return ;
}

最新文章

  1. bzoj3223
  2. [日常训练]string
  3. PHP的final关键字、static关键字、const关键字
  4. 怎么计算一个具体InnoDB的索引大小
  5. Python文件读取编码错误问题解决之(PyCharm开发工具默认设置的坑。。。)
  6. DROP_SNAPSHOT_RANGE过程不能清理表RM$_SNAPSHOT_DETAILS
  7. python数字图像处理(11):图像自动阈值分割
  8. 【iOS】iOS之Button segue弹出popOver消除(dismiss)问题
  9. Android开发笔记:安卓程序截屏方法
  10. Building Android Apps 30条建议
  11. nginx-tomcat-memcached架构文档说明(转)
  12. LinearGradientBrush,RadialGradientBrush的样式说明
  13. Maven 本地仓库明明有jar包,pom文件还是报错解决办法
  14. SpringMVC 使用MultipartFile实现文件上传(转)
  15. Java 环境下载设置
  16. 关于Python的Mixin模式
  17. Oracle中如何查询CLOB字段类型的内容
  18. Visual Studio2017 数据库架构比较
  19. 数据在内存中的存储方式( Big Endian和Little Endian的区别 )(x86系列则采用little endian方式存储数据)
  20. Linux 集群架构

热门文章

  1. sql注入问题 java中将MySQL的数据库验证秘密加上 &#39; or &#39;1&#39;= &#39;1 就可以出现万能密码
  2. JavaScript 交换两个变量的值
  3. [BZOJ] 2044: 三维导弹拦截
  4. 详解----memcache服务端与客户端
  5. node 中的redis使用
  6. Aliyun ECS简单的安装nginx(1.8.0)
  7. vue.js 三(数据交互)isomorphic-fetch
  8. centos7.3网络配置
  9. Codeforces Round #461 (Div. 2) C. Cave Painting
  10. hadoop伪分布式集群的搭建