本题题意很好读,看上去也不难写
写完运行才发现输出title只有一个单词...
后来把cin >> t换成了getline(cin, t)
还有一个坑点:
Line #1: the 7-digit ID number;
故输出要用%07d

采用的数据结构是map<string, set >

开了很多这样的map

还有key的读入,也需要记忆

/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue> typedef long long LL;
typedef unsigned long long ULL;
using namespace std; bool Sqrt(LL n) { return (LL)sqrt(n) * sqrt(n) == n; }
const double PI = acos(-1.0), ESP = 1e-10;
const LL INF = 99999999999999;
const int inf = 999999999;
int N, M;
map<string, set<int> > title, author, key, pub, year; void Q(map<string, set<int> > & mp, string & str)
{
if(mp.find(str) != mp.end()) {
for(auto u : mp[str]) printf("%07d\n", u);
// for(set<int>::iterator it = mp[str].begin(); it != mp[str].end(); it++)
// printf("%07d\n", *it);
}
else puts("Not Found");
} int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
scanf("%d", &N);
for(int i = 0; i < N; i++) {
int id; scanf("%d\n", &id);
string t; getline(cin, t);
title[t].insert(id);
getline(cin, t); author[t].insert(id);
while(cin >> t) {
key[t].insert(id);
if(getchar() == '\n') break;
}
getline(cin, t); pub[t].insert(id);
getline(cin, t); year[t].insert(id);
}
scanf("%d", &M);
while(M--) {
int num;
string s;
scanf("%d: ", &num);
getline(cin, s);
cout << num << ": " << s << "\n";
if(num == 1) Q(title, s);
else if(num == 2) Q(author, s);
else if(num == 3) Q(key, s);
else if(num == 4) Q(pub, s);
else if(num == 5) Q(year, s);
} return 0;
}
/*
input:
output:
modeling:
methods:
complexity:
summary:
*/

1022 Digital Library (30分)的更多相关文章

  1. PAT 甲级 1022 Digital Library (30 分)(字符串读入getline,istringstream,测试点2时间坑点)

    1022 Digital Library (30 分)   A Digital Library contains millions of books, stored according to thei ...

  2. 1022 Digital Library (30 分)

    1022 Digital Library (30 分)   A Digital Library contains millions of books, stored according to thei ...

  3. PAT Advanced 1022 Digital Library (30 分)

    A Digital Library contains millions of books, stored according to their titles, authors, key words o ...

  4. 【PAT甲级】1022 Digital Library (30 分)(模拟)

    题意: 输入一个正整数N(<=10000),接下来输入N组数据,ID,书名,作者,关键词,出版社,出版年份. 然后输入一个正整数M(<=1000),接下来输入查询的数据,递增输出ID,若没 ...

  5. pat 甲级 1022. Digital Library (30)

    1022. Digital Library (30) 时间限制 1000 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A Di ...

  6. 1022 Digital Library (30)(30 分)

    A Digital Library contains millions of books, stored according to their titles, authors, key words o ...

  7. 1022. Digital Library (30)

    A Digital Library contains millions of books, stored according to their titles, authors, key words o ...

  8. 1022. Digital Library (30) -map -字符串处理

    题目如下: A Digital Library contains millions of books, stored according to their titles, authors, key w ...

  9. 1022 Digital Library (30)(30 point(s))

    problem A Digital Library contains millions of books, stored according to their titles, authors, key ...

  10. PAT-1022 Digital Library (30 分) 字符串处理

    A Digital Library contains millions of books, stored according to their titles, authors, key words o ...

随机推荐

  1. 记录解决方案(sqlserver篇)

    一个月的补卡次数不超过三次(即统计一个月内某人的补卡次数) 表结构是某人一天内的四次打卡状态,这样是统计当月补卡的天数了(错误) select count(*) from [Proc_HR_Punch ...

  2. iOS SDK开发

    一款好用且设计充分的 SDK 必须要遵循以下 4 条基本原则,即: 1.SDK 安全,稳定2.统一的开发规范3.Library 小而精4.不依赖第三方 SDK安全,稳定:考虑到 SDK 是需要嵌入到 ...

  3. windows服务包装程序

    有些程序想随windows启动而自动运行,这样部署为windows服务是最自然的选择,但是有些第三方的程序,没有提供windows 服务的部署方式,或者自己写的程序,每次都要为部署为windows服务 ...

  4. Java中的左移、右移详细分析

    转自csdn--https://blog.csdn.net/weixin_42408447/article/details/125914449 前提:<<(左移),>>(右移) ...

  5. winform time.AddMinutes 时间相加

    最近修改代码,要求过滤掉重复的确认. 判断条件是(收费标记&&超时时间) 代码是这样的 1 TempRecordTableAdapter tempAda = new TempRecor ...

  6. js两个数组对象中,获取不相同的值 非交集元素对象

    查看前端面试题小程序 大量面试题和答案,请微信查看 var array1 = [ {"Num": "A " },{"Num": " ...

  7. express的使用:接口的编写(三)

    1.接口的跨域问题 a.CORS,主流 b.JSONP,只支持get请求 步骤:a.安装 npm install cors b.使用  const cors = require('cors') 导入中 ...

  8. OWASP ZAP基本使用教程(Kali版)

    简介OWASP ZAP是一款非常好用的测试工具,也是Kali里自带的工具,一键就可以扫描多种不同类型的漏洞,最好用的一点就是他可以自动爬取子域名.非常的快捷方便下面我就给大家带来OWASP ZAP的基 ...

  9. kibana启动时报错:Validation Failed: 1: this action would add [2] total shards, but this cluster currently has [999]/[1000] maximum shards open

    解决方案: curl -XPUT -H "Content-Type:application/json" -d '{"persistent":{"clu ...

  10. C# 屏蔽词过滤

    参考:https://www.cnblogs.com/kubidemanong/p/10834993.html public class TreeNode { public char Char; pu ...