100722B
在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的更多相关文章
随机推荐
- ArrayList如何实现线程安全
一:使用synchronized关键字,这个大家应该都很熟悉了,不解释了: 二:使用Collections.synchronizedList();使用方法如下: 假如你创建的代码如下:List< ...
- AC日记——单词替换 1.7 21
21:单词替换 总时间限制: 1000ms 内存限制: 65536kB 描述 输入一个字符串,以回车结束(字符串长度<=100).该字符串由若干个单词组成,单词之间用一个空格隔开,所有单词区 ...
- nodejs里的module.exports和exports的关系
关于node里面的module.exports和exports的异同,网上已经有很多的资料,很多的文章,很多的博客,看了很多,好像懂了,又好像不懂,过几天又不懂了...大致总结是这样的: //下面这种 ...
- Html5 Egret游戏开发 成语大挑战(七)游戏逻辑和数据处理
本篇在前面的基础上,将进行逻辑的编码开发让游戏能够正式的玩起来,这里没有注重太多的体验细节,而是直接实现游戏的规则逻辑,将分成两个部分说明:数据处理和游戏逻辑. 初始化游戏数据 在前面的第五篇中,我们 ...
- Cordova - 使用Cordova开发iOS应用实战5(获取手机里照片,并编辑)
使用Cordova可以很方便的通过js代码读取系统相簿里面的照片,同使用设备摄像头拍照一样,同样需要先添加camera插件. 一,添加camera插件 首先我们要在“终端”中进入工程所在的目录,然后运 ...
- Android 开发之旅:view的几种布局方式及实践
本文的主要内容就是分别介绍以上视图的七种布局显示方式效果及实现,大纲如下: 1.View布局概述 2.线性布局(Linear Layout) 2.1.Tips:android:layout_weigh ...
- Centos 7 安装 和 卸载 Mysql5.7(压缩包)
今天装的了mysql,遇到了很多问题,好在最后一一解决了,现在记录在此,防止日后老路重走... 1.下载 当然是去官网,下一个linux下的版本,64位的 tar.gz,好吧这里贴个名字--[mysq ...
- 关于Microsoft Visual Studio 2010系统自带的数据库
转自:http://blog.sina.com.cn/s/blog_a570cca601012x5w.html 1.Visual studio Tools>命令提示 2.aspnet_regsq ...
- springmvc请求参数异常处理
接着上一篇<springmvc 通过异常增强返回给客户端统一格式>讲通过spring ControllerAdvice对各种异常进行拦截处理,统一格式返回给客户端. 接下来我们更精细的讲, ...
- C语言复习(1)
test.c #include <stdio.h> int main(){ printf("hello\n"); return 0; } 1.预处理阶段 由于在test ...