1022 Digital Library

1022 Digital Library
分数 30

全屏浏览

切换布局
作者 CHEN, Yue
单位 浙江大学
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 (≤10 4) 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:
3
1111111
The Testing Book
Yue Chen
test code debug sort keywords
ZUCS Print
2011
3333333
Another Testing Book
Yue Chen
test code sort keywords
ZUCS Print2
2012
2222222
The Testing Book
CYLL
keywords debug book
ZUCS Print2
2011
6
1: The Testing Book
2: Yue Chen
3: keywords
4: ZUCS Print
5: 2011
3: blablabla
Sample Output:
1: The Testing Book
1111111
2222222
2: Yue Chen
1111111
3333333
3: keywords
1111111
2222222
3333333
4: ZUCS Print
1111111
5: 2011
1111111
2222222
3: blablabla
Not Found

1.分析

        1.模拟,字典存储序号,取出序号排序输出。

        2.关键字要拆分成单词记录

2.代码

#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
const int MAX=1e5+10;
struct node{string b[7];
}a[MAX];
int n,k;
map<string,vector<int>> m;
int main(){cin>>n;getchar();for(int i=0;i<n;i++){for(int j=0;j<6;j++){string str;getline(cin,str);a[i].b[j]=str;if(j==3){            //拆分成单词int f=0,e;while(str.find(' ',f)!=string::npos){e=str.find(' ',f);string re=str.substr(f, e - f);m[re].push_back(i);f=e+1;}string re=str.substr(f, e - f);m[re].push_back(i);}else m[a[i].b[j]].push_back(i);}}cin>>k;while(k--){       //输出char ch,s;string str;cin>>ch>>s;cin.get();getline(cin,str);cout<<ch<<": "<<str<<endl;vector<string> v;for(int i=0;i<m[str].size();i++){     //找到idint x=m[str][i];v.push_back(a[x].b[0]);}sort(v.begin(),v.end());      //排序for(int i=0;i<v.size();i++){cout<<v[i]<<endl;}if(m[str].size()==0) cout<<"Not Found"<<endl;}return 0;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/76869.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

地理人工智能中位置编码的综述:方法与应用

以下是对论文 《A Review of Location Encoding for GeoAI: Methods and Applications》 的大纲和摘要整理&#xff1a; A Review of Location Encoding for GeoAI: Methods and Applications 摘要&#xff08;Summary&#xff09; 本文系统综述了地理人工智能&#xff08;G…

(C语言)算法复习总结2——分治算法

1. 分治算法的定义 分治算法&#xff08;Divide and Conquer&#xff09;是一种重要的算法设计策略。 “分治” 从字面意义上理解&#xff0c;就是 “分而治之”。 它将一个复杂的问题分解成若干个规模较小、相互独立且与原问题形式相同的子问题&#xff0c;然后递归地解决这…

爱普生FC1610AN5G手机中替代传统晶振的理想之选

在 5G 技术引领的通信新时代&#xff0c;手机性能面临前所未有的挑战与机遇。从高速数据传输到多任务高效处理&#xff0c;从长时间续航到紧凑轻薄设计&#xff0c;每一项提升都离不开内部精密组件的协同优化。晶振&#xff0c;作为为手机各系统提供稳定时钟信号的关键元件&…

Android 接口定义语言 (AIDL)

目录 1. 本地进程调用(同一进程内)2. 远程进程调用(跨进程)3 `oneway` 关键字用于修改远程调用的行为Android 接口定义语言 (AIDL) 与其他 IDL 类似: 你可以利用它定义客户端与服务均认可的编程接口,以便二者使用进程间通信 (IPC) 进行相互通信。 在 Android 上,一个进…

关于QT5项目只生成一个CmakeLists.txt文件

编译器自动检测明明可以检测,Kit也没有报红 但是最后生成项目只有一个文件 一&#xff1a;检查cmake版本&#xff0c;我4.1版本cmake一直报错 cmake3.10可以用 解决之后还是有问题 把环境变量加上去&#xff1a;

uniapp小程序位置授权弹框与隐私协议耦合(合而为一)(只在真机上有用,模拟器会分开弹 )

注意&#xff1a; 只在真机上有用&#xff0c;模拟器会分开弹 效果图&#xff1a; 模拟器效果图&#xff08;授权框跟隐私政策会分开弹&#xff0c;先弹隐私政策&#xff0c;同意再弹授权弹框&#xff09;&#xff1a; manifest-template.json配置&#xff08; "__usePr…

[Godot] C#人物移动抖动解决方案

在写一个2D平台跳跃的游戏代码发现&#xff0c;移动的时候会抖动卡顿的厉害&#xff0c;后来研究了一下抖动问题&#xff0c;有了几种解决方案 1.垂直同步和物理插值问题 这是最常见的可能导致画面撕裂和抖动的原因&#xff0c;大家可以根据自己的需要调整项目设置&#xff0…

红帽Linux网页访问问题

配置网络&#xff0c;手动配置 搭建yum仓库红帽Linux网页访问问题 下载httpd 网页访问问题&#xff1a;首先看httpd的状态---selinux的工作模式&#xff08;强制&#xff09;---上下文类型(semanage-fcontext)---selinux端口有没有放行semanage port ---防火墙有没有active---…

Android12编译x86模拟器报找不到userdata-qemu.img

qemu-system-x86_64: Could not open out/target/product/generic_x86_64/userdata-qemu.img: No such file or directory 选择编译aosp_x86-eng时没有生成模拟器&#xff0c;报 qemu-system-x86_64: Could not open out/target/product/generic_x86_64/userdata-qemu.img: No…

【AI论文】PixelFlow:基于流的像素空间生成模型

摘要&#xff1a;我们提出PixelFlow&#xff0c;这是一系列直接在原始像素空间中运行的图像生成模型&#xff0c;与主流的潜在空间模型形成对比。这种方法通过消除对预训练变分自编码器&#xff08;VAE&#xff09;的需求&#xff0c;并使整个模型能够端到端训练&#xff0c;从…

AI大模型学习九:‌Sealos cloud+k8s云操作系统私有化一键安装脚本部署完美教程(单节点)

一、说明 ‌Sealos‌是一款基于Kubernetes&#xff08;K8s&#xff09;的云操作系统发行版&#xff0c;它将K8s以及常见的分布式应用如Docker、Dashboard、Ingress等进行了集成和封装&#xff0c;使得用户可以在不深入了解复杂的K8s底层原理的情况下&#xff0c;快速搭建起一个…

【HDFS入门】HDFS核心组件DataNode详解:角色职责、存储机制与健康管理

目录 1 DataNode的角色定位 2 DataNode的核心职责 2.1 数据块管理 2.2 与NameNode的协作 3 DataNode的存储机制 3.1 数据存储目录结构 3.2 数据块文件组织 4 DataNode的工作流程 4.1 数据写入流程 4.2 数据读取流程 5 DataNode的健康管理 5.1 心跳机制&#xff08;…

BufferedOutputStream 终极解析与记忆指南

BufferedOutputStream 终极解析与记忆指南 一、核心本质 BufferedOutputStream 是 Java 提供的缓冲字节输出流&#xff0c;继承自 FilterOutputStream&#xff0c;通过内存缓冲区显著提升 I/O 性能。 核心特性速查表 特性说明继承链OutputStream → FilterOutputStream → …

光纤模块全解:深入了解XFP、SFP、QSFP28等类型

随着信息技术的快速发展&#xff0c;数据中心和网络的带宽需求不断提高&#xff0c;光纤模块的选择与应用显得尤为重要。光纤模块是实现高速网络连接的重要组件&#xff0c;选择合适的模块能够显著提升传输性能、降低延迟。本文将深入解析几种常见的光纤模块类型&#xff0c;包…

【高阶数据结构】第三弹---图的存储与遍历详解:邻接表构建与邻接矩阵的BFS/DFS实现

✨个人主页&#xff1a; 熬夜学编程的小林 &#x1f497;系列专栏&#xff1a; 【C语言详解】 【数据结构详解】【C详解】【Linux系统编程】【高阶数据结构】 目录 1、图的存储结构 1.1、邻接表 1.1.1、边的结构 1.1.2、图的基本结构 1.1.3、图的创建 1.1.4、获取顶点下…

OpenCV的详细介绍与安装(一)

1.OpenCV概述 OpenCV是一个开源的计算机视觉和机器学习软件库&#xff0c; 它轻量级而且高效——由一系列 C 函数和少量 C 类构成&#xff0c;它支持多种编程语言&#xff08;如C、Python、Java&#xff09;&#xff0c;并可在Windows、Linux、macOS、Android和iOS等平台上运行…

STM32F103_HAL库+寄存器学习笔记15 - 梳理CAN发送失败时,涉及哪些寄存器

导言 《STM32F103_LL库寄存器学习笔记14 - CAN发送完成中断》上一章节完成CAN发送完成中断&#xff0c;在梳理二级发送缓存之前&#xff0c;先梳理怎样监控CAN发送失败。 如上所示&#xff1a; 当我关掉CAN分析仪的CAN通道1&#xff0c;CAN错误状态寄存器CAN_ESR的TEC&#x…

Linux——Shell编程之循环语句(笔记)

For循环语句 1、for语句的结构与逻辑&#xff1a; 使用for循环语句时&#xff0c;我们需要指定一个变量以及取值列表&#xff0c;针对每个不同的取值重复执行相同的命令序列,直到变量使用完退出循环。结构如下&#xff1a; for 变量 in 取值列表do命令序列done 对于for语句的…

【权限】v-hasPermi=“[‘monitor:job:add‘]“ 这个属性是怎么控制能不能看到这个按钮

背景&#xff1a;对于前台中通过指令对于操作按钮的控制是怎么实现的&#xff1a; <el-col :span"1.5"><el-buttontype"primary"plainicon"Plus"click"handleAdd"v-hasPermi"[system:role:add]">新增</el-bu…

ISIS路由引入

‌基本概念与作用‌ ISIS&#xff08;Intermediate System to Intermediate System&#xff09;协议的路由引入&#xff08;Route Import&#xff09;功能用于将其他路由协议&#xff08;如OSPF、BGP&#xff09;或静态/直连路由引入ISIS域&#xff0c;实现跨协议的路由信息共…