title: PTA 1071 Speech Patterns (25分) date: 2020-10-02 15:43:59 tags:
Map categories:[刷题,PAT]本文由参考于柳神博客写成
柳神的博客,这个可以搜索文章
柳神的个人博客,这个没有广告,但是不能搜索
PS 今天也要加油鸭
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.
Each input file contains one test case. For each case, the first line contains a positive integer N (≤104) 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 title2: name of an author3: a key word4: name of a publisher5: a 4-digit number representing the yearFor 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.
Digital 数字的
abstracts 摘要,抽象
给你N本书
然后给你这书的一些信息,分别是
id ,书名,作者,关键字–有多个.出版社.出版年份
然后再给N个查询,1 是查书名 2 是查作者,3 是查关键字,4是查出版社,5是查出版月份
要你给出查询到的id
我们用
map<string set<int>>来做,不过要注意关键字的keywords的录入.
还有就是getline 之前要读取多余的\n
char c =getchar();这题柳神的思路和我的差不多,就不贴了.有兴趣的,自己去柳神的Blog上去翻一番.
如果这篇文章对你有张帮助的话,可以用你高贵的小手给我点一个免费的赞吗
相信我,你也能变成光.
如果你有任何建议,或者是发现了我的错误,欢迎评论留言指出.