本题题意很好读,看上去也不难写
写完运行才发现输出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. 【转】BIO,NIO和AIO

    本文转自:https://blog.csdn.net/qxy_1218/article/details/123941039 BIO,NIO和AIO是Java网络编程的三种模型 BIO:同步并阻塞,服务 ...

  2. WPF 轨迹动画

    1.后台 public MainWindow() { InitializeComponent(); /// <summary> /// Window2.xaml 的交互逻辑 /// < ...

  3. List集合转换成数组

    我现在有个需求:将File集合转换成MultipartFile数组结构 然后我就开始在网上开启了List转换到数组之旅. 首先来看一个例子 ArrayList<String> list=n ...

  4. Python学习笔记组织文件之将指定目录下的指定格式文件压缩到指定文件夹

    随笔记录方便自己和同路人查阅. #------------------------------------------------我是可耻的分割线--------------------------- ...

  5. HDLbits——Rotate100

    verilog代码: // Build a 100-bit left/right rotator, with synchronous load and left/right enable. //A r ...

  6. B站小白STM32项目 第9课卡在OneNet_DevLink() 解决办法

    笔者在看这一集的时候,自己在emq官方上购买了服务器,于是就换成了自己的服务器和相应的mqtts端口, 买了两个服务器,但最后都卡在OneNet_DevLink() :要么连接不成功,要么显示连接申请 ...

  7. Lua中__index元方法的介绍与使用

    一.相关介绍请参考:Lua中__index原方法介绍 二.使用示例 代码如下: 下面示例使用的元素迭代器 --1.列表元素迭代器,仅返回列表中每一个元素,改列表索引必须为连续的数字 function ...

  8. 20191317Exp3-免杀原理与实践

    20191317Exp3-免杀原理与实践 基础问题回答 1.1 杀软是如何检测出恶意代码的? 基于特征码进行检测:杀毒软件的病毒库记录了一些恶意软件的特征码,一段特征码就是一段或多段数据.如果一个可执 ...

  9. 高级纹理以及复杂而真实的应用——ShaderCp10

    --20.9.7 这章主要分成三个部分 立方体纹理(cubemap) 渲染纹理(RenderTexture,rt) 和程序纹理 一.立方体纹理 立方体纹理顾名思义是一种三维的纹理形状类似于立方体,由六 ...

  10. 在Unity3D中开发的坦克履带模拟器Tank Track Simulator

    为了在Unity游戏中比较真实地模拟坦克履带的运动,本人便开发了这款Tank Track Simulator插件 特点 比较真实地模拟了坦克履带的运动. 本插件中包含了一辆M1A2坦克模型,已经将这个 ...