[OpenJudge-NOI]List stl
2015-11-05 13:50
239 查看
代码
#include <cstdio> #include <iostream> #include <cstring> #include <list> #include <map> using namespace std; map<int,list<int> > m; int n,x,y; char op[10000]; int main(){ scanf("%d",&n); while(n--){ scanf("%s",op); if(strcmp(op,"new")==0){ scanf("%d",&x); m.insert(map<int,list<int> >::value_type(x,list<int>())); } if(strcmp(op,"add")==0){ scanf("%d%d",&x,&y); m[x].push_back(y); } if(strcmp(op,"merge")==0){ scanf("%d%d",&x,&y); m[x].merge(m[y]); //m[y].clear(); } if(strcmp(op,"unique")==0){ scanf("%d",&x); m[x].sort(); m[x].unique(); } if(strcmp(op,"out")==0){ scanf("%d",&x); m[x].sort(); list<int>::iterator it; for(it=m[x].begin();it!=m[x].end();it++){ printf("%d ",*it); } printf("\n"); } } }
相关文章推荐
- linux下i2c驱动笔记
- Linux中将Apache加入到系统服务
- Linux Programing -- ch14-- 信号量、共享内存、消息队列
- 运维工程师必会的109个Linux命令
- 网站记录
- ubuntu15.10配置LNMP(linux+nginx+mysql+php)
- Linux 下打包压缩 war 和解压 war 包
- linux vim 命令
- Spark1.51 本地启动了Master和一个Slave后,在Spark-Shell里跑,看出sc.textFile找数据的stacktrace
- 使用Windows创建Nginx+Apache的负载均衡
- linux:输入输出重定向
- linux运维超级工具--sysdig
- 运维小命令
- Operating System: Three Easy Pieces ---An Example: Thread Creation (Note)
- 为什么Centos/Redhat6 里看到的网卡是em1 或者p2p1
- windows下WNMP(windows+nginx+mysql+php)配置
- Shell中将程序控制台输出复制到文件
- Tomcat的目录结构以及其用途
- rsync详解
- Maven 集成Tomcat插件