STL之双重map(map的second值也是一个map容器)
来源:互联网 发布:逆光源网络剧百度云盘 编辑:程序博客网 时间:2024/06/06 19:03
map容器还是很好用的,虽然效率不是亲手编写的那种高效率得应用,但是在acm中的编码效率和正确率却能够大大的提高,下面是一道双重map容器的应用
http://acm.hdu.edu.cn/showproblem.php?pid=1263
题意是中文,而且很简单,但是麻烦,用map嵌套就好了
- #include <iostream>
- #include <cstdio>
- #include <string>
- #include <map>
- #include <algorithm>
- #include <iomanip>
- using namespace std;
- map<string, map<string, int> > Map;
- map<string, int> mmap;
- int main()
- {
- int ncase, m;
- cin >> ncase;
- while(ncase--)
- {
- Map.clear();
- cin >> m;
- for(int i = 0; i < m; i++)
- {
- string name, loc;
- int num;
- cin >> name >> loc >> num;
- (Map[loc])[name] += num;
- }
- for(map<string, map<string, int> >::iterator it = Map.begin(); it != Map.end(); it++)
- {
- cout << it->first <<endl;
- for(map<string, int> ::iterator ii = it->second.begin(); ii != it->second.end(); ii++)
- {
- cout << setw(4) << "|";
- cout << "----";
- cout << ii->first <<"(" << ii->second << ")" << endl;
- }
- }
- if(ncase != 0)
- cout << endl;
- }
- return 0;
- }
0 0
- STL之双重map(map的second值也是一个map容器)
- STL之双重map(map的second值也是一个map容器)
- STL容器之map
- STL之Map容器
- STL之map容器
- STL之容器map
- STL容器之map
- 【STL】STL容器之map
- STL之map&multimap容器(笔记)
- STL学习之map容器(1)
- STL学习之map容器(0)
- STL学习之map容器(3)
- STL之MAP关联容器
- STL关联容器之Map
- STL 之 map 关联容器
- STL学习之map容器
- STL学习之map容器
- STL容器之Map,MulitMap
- Java学习笔记2
- 关于__int64,__int32,long long
- 总结UIView常见的用法
- rsync over ssh over socks
- Sicily 1193 Up the Stairs
- STL之双重map(map的second值也是一个map容器)
- OpenCL 笔记3 OpenCL和CUDA
- Android的进程与线程模型
- 4 Activity Fragment
- easyui dialog远程加载内容完成后,进行对话内容(表单)初始化
- excel如何快速把多个工作表合并到一个excel表
- 大型网站系统架构演化之路
- 程序员之路 1.
- 进入Vi 按方向键输出 ABCD 的解决方法