UVa12096 set map vector stack的综合运用
来源:互联网 发布:2017东南大学软件学院 编辑:程序博客网 时间:2024/04/30 13:58
UVa12096
#include<cstdio>#include<cstring>#include<iostream>#include<sstream>#include<algorithm>#include<queue>#include<stack>#include<vector>#include<set>#include<map>using namespace std;typedef set<int> Set;//set<int>表示含有集合的集合,如{ {},{} }表示为<1,1>map<Set,int> idMap;//将集合映射成idvector<Set> diffSet;//保存每一个不同的集合对应的Set,下标是idstack<int> stk;//保存集合对应的id,由diffSet[id]得到Setint findID(Set x){ if(idMap.count(x)>0) return idMap[x]; diffSet.push_back(x); int id=diffSet.size()-1; idMap[x]=id; return id;}int main(){ int t,n; char cmd[10]; scanf("%d",&t); while(t--) { scanf("%d",&n); while(n--) { scanf("%s",cmd); if(cmd[0]=='P') stk.push( findID(Set()) ); else if(cmd[0]=='D') stk.push(stk.top()); else{ Set x1=diffSet[stk.top()];stk.pop(); Set x2=diffSet[stk.top()];stk.pop(); Set x; if(cmd[0]=='U') set_union(x1.begin(),x1.end(),x2.begin(),x2.end(),inserter(x,x.begin()) ); else if(cmd[0]=='I') set_intersection(x1.begin(),x1.end(),x2.begin(),x2.end(),inserter(x,x.begin()) ); else if(cmd[0]=='A'){ x=x2; x.insert(findID(x1)); } stk.push(findID(x)); } printf("%d\n",diffSet[stk.top()].size()); } printf("***\n"); } return 0;}
0 0
- UVa12096 set map vector stack的综合运用
- UVA12096,STL stack和set,Map的综合运用
- UVA12096 the SetStack Computer(STL中,map,set,vector,stack联合应用)
- c++ map set综合运用
- UVa 12096 map ,vector,set,string ,stack的混用
- STL stack/queue/sort/vector/set/map 的使用方法
- map容器的使用 加上一个map与set综合运用的例子
- UVA12096 - The SetStack Computer(set + map映射)
- vector map set的使用
- STL 整理map、set、vector、list、stack、queue、deque、priority_queue
- java类集(List/Set/Map/Iterator)(Enumeration/Vector/Stack/Properties)
- uva 12096 例题5-5 map vector set stack 混用
- STL详解(vector,list,deque,stack,queue,priority_queue;map,set)
- map、set、vector、list、stack、queue、deque、priority_queue
- c++STL容器(map,set,vector,stack,queue)
- STL讲解 容器(map,set,vector,stack,queue)
- List(LinkedList,ArrayList,Vector,Stack),Set,Map(Hashtable,HashMap)
- C++ map;vector;list;queue;stack;set对比使用
- 关于jQuery写插件及其演示
- POJ-3682King Arthur's Birthday Celebration(概率DP)
- python脚本 #!usr/bin/python的作用
- 设计模式:常见类的关系小结
- Git五分钟教程
- UVa12096 set map vector stack的综合运用
- 京东云、新浪微博等专家畅谈Docker未来格局:开放与竞争(下)
- JAVA基础----接口
- PAT乙级 1011. A+B和C
- 多态之一(继承和虚函数)
- Android Studio 简介及导入 jar 包和第三方开源库方
- 浅谈JVM内存区域划分
- 判断一个单链表是否有环及环的链接点
- POJ 2773 Happy 2006