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的更多相关文章
随机推荐
- 第六章、Struts2数据校验
一.三种实现方式 ① 用validate()方法实现数据校验 继承ActionSupport类,该类实现了Validateable接口,该接口中定义了一个validate()方法,在自定义的Actio ...
- Maven学习(三)生命周期
maven有三套生命周期 1.clean 清理项目 2.default 构建项目 3.site 建立项目站点 每套生命周期都包含了一些阶段,这些阶段是有序的,后 ...
- [转]关于vs调试正确。但是发布到iis就出现无法访问后天局面
最近使用extjs+ashx进行ajax请求过程操作的时候发现一个问题..当我把程序发布到iis的时候就出现一只不执行到success回调函数. 当弹出状态值一看尽然是500.我就纳闷了.又没有语法错 ...
- java 27 - 3 反射之 通过反射获取构造方法并使用
类 Constructor<T>:提供关于类的单个构造方法的信息以及对它的访问权限. 通过反射的方法获取构造方法并使用 ps:先忽略泛型 A.1:获取构造方法的数组: public Co ...
- ie9及以下不兼容event.target.dataset对象
ie9及以下不兼容event.target.dataset对象,请使用event.target.getAttribute('data-xxx')
- 定时取数据库的schema,并推送到git服务器
写了个脚本,定时去数据库取schema,并推送到公司的git里. #daily_schema.py #/usr/bin/env python import os import datetime,tim ...
- Padrino 生成器指南
英文版出处:http://www.padrinorb.com/guides/generators Padrino提供了用于快速创建应用的生成器,其优势在于构建推荐的Padrino应用结构.自动生成罗列 ...
- C语言 malloc()与sizeof运算的盲点
//malloc()与sizeof运算的盲点 #include <stdio.h> #include <stdlib.h> #include <string.h> ...
- 程序开发使用docker部署
我们公司自己研发了一套 grand-line 系统,使用 docker 来部署项目. 我是第一批小白鼠,一开始网络差,build 一次要半个小时,连接进入 web shell 也很慢,部署一个微信项目 ...
- TinyFrame升级之八:实现简易插件化开发
本章主要讲解如何为框架新增插件化开发功能. 在.net 4.0中,我们可以在Application开始之前,通过PreApplicationStartMethod方法加载所需要的任何东西.那么今天我们 ...