1022 Digital Library (30分)
本题题意很好读,看上去也不难写
写完运行才发现输出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分)的更多相关文章
- PAT 甲级 1022 Digital Library (30 分)(字符串读入getline,istringstream,测试点2时间坑点)
1022 Digital Library (30 分) A Digital Library contains millions of books, stored according to thei ...
- 1022 Digital Library (30 分)
1022 Digital Library (30 分) A Digital Library contains millions of books, stored according to thei ...
- PAT Advanced 1022 Digital Library (30 分)
A Digital Library contains millions of books, stored according to their titles, authors, key words o ...
- 【PAT甲级】1022 Digital Library (30 分)(模拟)
题意: 输入一个正整数N(<=10000),接下来输入N组数据,ID,书名,作者,关键词,出版社,出版年份. 然后输入一个正整数M(<=1000),接下来输入查询的数据,递增输出ID,若没 ...
- pat 甲级 1022. Digital Library (30)
1022. Digital Library (30) 时间限制 1000 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A Di ...
- 1022 Digital Library (30)(30 分)
A Digital Library contains millions of books, stored according to their titles, authors, key words o ...
- 1022. Digital Library (30)
A Digital Library contains millions of books, stored according to their titles, authors, key words o ...
- 1022. Digital Library (30) -map -字符串处理
题目如下: A Digital Library contains millions of books, stored according to their titles, authors, key w ...
- 1022 Digital Library (30)(30 point(s))
problem A Digital Library contains millions of books, stored according to their titles, authors, key ...
- PAT-1022 Digital Library (30 分) 字符串处理
A Digital Library contains millions of books, stored according to their titles, authors, key words o ...
随机推荐
- Web开发 学习 调试 调优
目录 快捷操作 调试方法 基本调试方法 修改参数和请求重发 Chrome抓包分析 性能优化 安全 cURL请求 参考 参考:MDN 调试HTML 参考:什么是浏览器开发者工具? 参考:检查和编辑页面与 ...
- select remove option safari 兼容
select 移除某一 option 的 javascript 公司用的代码是 var ddlPrimaryResource = document.getElementById(ddlPrimaryR ...
- 镜像问题、简易安装,系统语言更改,中文输入,提高下载速度,Firefox的语言更改,Firefox上网速度慢
一开始用的镜像不记得是从哪里下载过来的,反正 装好之后分辨率特别低.镜像放在: "D:\迅雷下载\2020大创\Ubuntu\ubuntu-16.04.6-desktop-i386.iso& ...
- okHttp3源码简要分析
首先看一下使用, public static void main(String[] args) throws IOException { OkHttpClient client = new OkHtt ...
- spring缓存创建
/** * * <b>创建缓存</b> * <p> * 创建缓存,若已存在直接返回. * <p> * @param cacheName * @retur ...
- 2020icpc济南 - A
组合数学 + 高斯消元 [A-Matrix Equation_第 45 届国际大学生程序设计竞赛(ICPC)亚洲区域赛(济南) (nowcoder.com)](https://codeforces.c ...
- vue项目前台带表格的页面,让表格根据屏幕大小自适应高度,小屏幕时不出现多个滚动条
参见馆藏库房系统, 右侧整体结构一般如下 <el-container class="ml10 mr10 br7 bgw"> <el-main> // el- ...
- vue 收藏
html: //收藏 <el-table-column prop="isOpen" label=""> <te ...
- pycharm 默认添加# -*-coding: utf-8 -*-
备忘 pycharm创建py文件时,默认输入表头信息 1.点击[File]-[Settins] 2.点击[Editor]-[File and Code Templates] 3.点击[Python S ...
- ES6 - 参数默认值
1.形参初始值, 具有默认值的参数,一般位置要靠后(潜规则) function add(a,b,c=10){ return a + b + c; } let resutl = add(1,2); // ...