PAT甲级 - 1022 Digital Library (30 分)

叁歲伎倆 2022-03-17 01:16 278阅读 0赞

题目链接:PAT甲级 - 1022 Digital Library (30 分)

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 (≤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 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:

  1. 3
  2. 1111111
  3. The Testing Book
  4. Yue Chen
  5. test code debug sort keywords
  6. ZUCS Print
  7. 2011
  8. 3333333
  9. Another Testing Book
  10. Yue Chen
  11. test code sort keywords
  12. ZUCS Print2
  13. 2012
  14. 2222222
  15. The Testing Book
  16. CYLL
  17. keywords debug book
  18. ZUCS Print2
  19. 2011
  20. 6
  21. 1: The Testing Book
  22. 2: Yue Chen
  23. 3: keywords
  24. 4: ZUCS Print
  25. 5: 2011
  26. 3: blablabla

Sample Output:

  1. 1: The Testing Book
  2. 1111111
  3. 2222222
  4. 2: Yue Chen
  5. 1111111
  6. 3333333
  7. 3: keywords
  8. 1111111
  9. 2222222
  10. 3333333
  11. 4: ZUCS Print
  12. 1111111
  13. 5: 2011
  14. 1111111
  15. 2222222
  16. 3: blablabla
  17. Not Found

发表评论

表情:
评论列表 (有 0 条评论,278人围观)

还没有评论,来说两句吧...

相关阅读

    相关 PAT甲级1030 Travel Plan (30)

    题解: 题目大意是告诉你每个城市间的距离和开销,让你求出从起点到终点的最短距离,然后如果距离相同的话要最小开销,最后输出这条最短的路径、最小距离和最小开销 思路: