UVa12096(集合中的集合+stl)集合栈计算机
//一个集合代表一个数字,神奇的操作
#include<set>
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<stack>
#include<algorithm>
using namespace std;
string str;
stack<int> s;
typedef set<int> Set;
map<Set,int> mp;
vector<Set> setcache;
int ID(Set x)
{
//查找集合x的编号,如果没找到,就为其新建一个编号
if(mp.count(x)) return mp[x];
setcache.push_back(x);
return mp[x]=setcache.size()-1;
}
int main()
{
int T,n;
cin>>T;
while(T--)
{
scanf("%d",&n);
while(n--)
{
cin>>str;
if(str[0]=='P') s.push(ID(Set()));//空集入栈
else if(str[0]=&
还没有评论,来说两句吧...