PAT1022——Digital Library
来源:互联网 发布:淘宝怎样设置分享有赏 编辑:程序博客网 时间:2024/05/17 06:22
这题主要在于要做5张map<string, set<string>>做出索引来,还有getcin、getchar的用法,直接po代码了。
int n, m;map<string, set<string>> book[5];int main(){ cin>>n; for(int i = 0; i<n; i++){ string id; cin>>id; getchar(); string temp; set<string> temp1; for(int j = 0; j<5; j++){ if(j == 2){ do{ cin>>temp; if(book[j].count(temp) == 0){ temp1.insert(id); book[j].insert(pair<string, set<string>>(temp, temp1)); } else book[j][temp].insert(id); }while(getchar() != '\n'); continue; } getline(cin, temp); if(book[j].count(temp) == 0){ temp1.insert(id); book[j].insert(pair<string, set<string>>(temp, temp1)); } else book[j][temp].insert(id); temp1.clear(); } } cin>>m; string temp;int num; for(int i = 0; i<m; i++){ scanf("%d: ", &num); getline(cin, temp); cout<<num<<": "<<temp<<endl; num--; if(book[num].count(temp) == 0) cout<<"Not Found"<<endl; else{ set<string, string>::iterator it; for(it = book[num][temp].begin(); it != book[num][temp].end(); it++){ cout<<*it<<endl; } } } return 0;}
阅读全文
0 0
- PAT1022——Digital Library
- PAT1022. Digital Library
- PAT1022. Digital Library
- PAT1022 Digital Library 格式题...
- PAT1022~~~
- 什么是数字图书馆——What is Digital Library?
- 1022. Digital Library (30)——PAT (Advanced Level) Practise
- 一个似乎应该高度关注的名词—Digital Library
- Digital Library
- Digital Library
- 1022. Digital Library (30)
- 1022. Digital Library
- PAT_1022: Digital Library
- 1022. Digital Library (30)
- 1022. Digital Library (30)
- 1022. Digital Library (30)
- 1022. Digital Library (30)
- 1022. Digital Library (30)
- 微信小程序后台返回中文乱码问题
- HBuilder常用快捷键
- 线程优先级
- 第一个hibernate程序
- 周末愉快
- PAT1022——Digital Library
- AndroidStudio 导入AOSP
- 一种基于目光追踪技术的移动设备辅助操作系统/ 针对于高位截瘫,渐冻人,脑瘫患者的简易手机操作软件设计
- 216. Combination Sum III
- hadoop体系结构
- 嵌入式系统概论-1.3
- linunx centos 6.5 安装redis 和ngnix
- fabric 部署 python web 应用的基本config
- elasticsearch集群快速上手搭建