hdu4022-bomb stl
来源:互联网 发布:php深入好难 编辑:程序博客网 时间:2024/05/16 22:38
stl应用:
list map
新学:remove(value):找到容器中所有等于value的元素并删除之
#include <iostream>#include <map>#include <cstdio>#include <list>using namespace std;int main(){ int n,m; map<int ,list<int> x; map<int ,list<int> > y; while(~scanf("%d%d",&n,&m) && (m!=0 || n!=0)){ x.clear(),y.clear(); int a,b; for(int i=0;i<n;i++){//十字链表 scanf("%d%d",&a,&b); x[a].push_front(b); y[b].push_front(a); } for(int i=0;i<m;i++){ int base,dir; scanf("%d%d",&dir,&base); int num; if(dir==0){ num=x[base].size(); printf("%d\n",num); list<int>::iterator it; for(it=x[base].begin();it!=x[base].end();it++) { y[*it].remove(base);//找到链中等于base的元素并且删除。 } x[base].clear();//bomb!!!! } else{ num=y[base].size(); printf("%d\n",num); list<int>::iterator it; for(it=y[base].begin();it!=y[base].end();it++) { x[*it].remove(base); } y[base].clear(); } } printf("\n"); } return 0;}
0 0
- hdu4022-bomb stl
- hdu4022
- hdu4022
- hdu4022
- hdu4022 Bombing stl(map+set)
- HDU4022(二分法)
- Bomb
- Bomb
- Bomb
- Bomb
- Bomb
- bomb
- Bomb
- Bomb
- bomb
- hdu4022 离散化
- hdu4022 map+multiset
- hdu3555 Bomb
- 快速排序
- 设计模式笔记-解析器模式
- Linux sqlplus执行*.sql文件
- Riak VClock
- CSS实战手册_阅读笔记08_文本格式化
- hdu4022-bomb stl
- Use AES Encrypt And Decrypt With Custom Key( Expand AesCryptoServiceProvider Class)
- linkin大话数据结构--Map
- 后缀表达式建立二叉树并遍历测试
- C++11之std::bind
- 设计模式概述
- Android Localization Tutorial (Android 本地化)
- Java并发与同步
- ASP.NET GridView.DataSource=NULL