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.pswp.cn/pingmian/76869.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/76869.shtml
英文地址,請注明出處:http://en.pswp.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;實現跨協議的路由信息共…