在stack里套set,然后每次根据他的操作,在set里操作,把括号hash,插入,输出set的size-1

#include<iostream>
#include<set>
#include<cstdio>
#include<stack>
#define ll long long
#define st set<ll>
using namespace std;
stack<st>s;
ll T,n,tot;
char S[];
int main()
{
cin>>T;
while(T--)
{
cin>>n;
while(!s.empty())s.pop();
for(int i=;i<=n;i++)
{
scanf("%s",S);
if(S[]=='P')
{
st x;x.clear();
x.insert();
s.push(x);
printf("%d\n",);
}
if(S[]=='D')
{
st a;a.clear();
a=s.top();
ll temp=a.size()-;
s.push(a);
printf("%d\n",temp);
}
if(S[]=='U')
{
st a=s.top();s.pop();
st b=s.top();s.pop();
for(st::iterator it=a.begin();it!=a.end();it++)
b.insert(*it);
s.push(b);
printf("%d\n",b.size()-);
}
if(S[]=='I')
{
st a=s.top();s.pop();
st b=s.top();s.pop();
st c;c.clear();
for(st::iterator it=a.begin();it!=a.end();it++)
if(b.count(*it))c.insert(*it);
s.push(c);
printf("%d\n",c.size()-);
}
if(S[]=='A')
{
st a=s.top();s.pop();
st b=s.top();s.pop();
st c;c.clear();
ll sum=;
for(st::iterator it=a.begin();it!=a.end();it++)
{sum*=;sum+=*it;}
sum*=;
b.insert(sum);
s.push(b);
printf("%d\n",b.size()-);
}
}
printf("***\n");
}
return ;
}

100722B的更多相关文章

随机推荐

  1. URL和URI区别

         URI:Universal Resource Identifier,通用资源标识符:   URL:Uniform Resource Locator,统一资源定位符:   其中,URL是URI ...

  2. [No00000F]Excel快捷键大全 Excel2013/2010/2007/2003常用快捷键大全

    一个软件最大的用处是提高工作效率,衡量一个软件的好坏,除了是否出名之外,最主就是能否让一个新手更快的学会这个软件和提高工作速度.就拿Excel表格来说吧,平常办公中我们经常会用它来制作表格,统计数据或 ...

  3. pullRefresh组件配置

    mui.init({ pullRefresh:{ container: '#contanier', indicators:false, up:{ height:200, contentinit: '' ...

  4. PHP 图片处理PNG颜色丢失

    根据需求做一个用户点击测试桃花运的小程序.在开发中需要使用PHP进行开发,原理是将用户的姓名通过php的图片处理写入图片中,此处遇到一巨坑. 就是png图片在调用 imagecolorallocate ...

  5. Tomcat 开启 SSL

    生成keystore /usr/java/default/bin/keytool -genkey -alias tomcat -keyalg RSA -keystore ~/tomcat.keysto ...

  6. C# winform生成天气预报(转)

    原文地址 http://www.cnblogs.com/ChowYy/p/3382216.html?utm_source=tuicool&utm_medium=referral 项目需要,然后 ...

  7. 在linux下运行java工程

    在linux 服务器上运行JAVA工程需注意.1: 在linux 上: /etc/profile  设置classpath 配置正确的jar 路径.2:  把本地JAVA工程做成一个jar包.如:1. ...

  8. Cannot resolve external dependency com.android.support:multidex:1.0.0

    multiDexEnabled true 去掉这一行,就OK了,是没有多dex支持么,但是又提供了这个

  9. nginx学习(1):编译、安装、启动

    一.下载 从官网http://nginx.org/en/download.html 下载稳定版(目前最新稳定版是1.6.2) 二.解压 tar zxf nginx-1.6.2.tar.gzcd ngi ...

  10. centos6-honeyd安装&配置

    安装 需要装 libpcap libevent libdnet 等(!) 有些用的yum,有些下载的安装包手动安装 (wget tar configure make install 非常linux) ...