队列,$map$。

每次出队进行出队操作的是时候,先把队列中需要出队的人全部出队,然后比较对头和当前出队的人是否相同。

#include<bits/stdc++.h>
using namespace std;
int T,n,sz,sum;
int f[];
char op[];
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d",&n); sum=sz=;
map<string,int>zhuan;
queue<int>Q;
memset(f,,sizeof f);
for(int i=;i<=n;i++)
{
scanf("%s",op);
if(op[]=='i')
{
scanf("%s",op);
zhuan[op]=++sz;
Q.push(sz);
}
else
{
while()
{
if(Q.empty()) break;
if(f[Q.front()]==) break;
Q.pop();
}
scanf("%s",op);
int id = zhuan[op];
f[id]=;
if(Q.front()!=id) sum++;
}
}
printf("%d\n",n/-sum);
}
return ;
}

BNUOJ 52511 Keep In Line的更多相关文章

  1. bnuoj 4209 Triangle(计算几何)

    http://www.bnuoj.com/bnuoj/problem_show.php?pid=4209 题意:如题 题解:公式直接计算,或者角平分线求交点 [code1]: #include < ...

  2. BNUOJ 52303 Floyd-Warshall Lca+bfs最短路

    题目链接: https://www.bnuoj.com/v3/problem_show.php?pid=52303 Floyd-Warshall Time Limit: 60000msMemory L ...

  3. ILJMALL project过程中遇到Fragment嵌套问题:IllegalArgumentException: Binary XML file line #23: Duplicate id

    出现场景:当点击"分类"再返回"首页"时,发生error退出   BUG描述:Caused by: java.lang.IllegalArgumentExcep ...

  4. Error on line -1 of document : Premature end of file. Nested exception: Premature end of file.

    启动tomcat, 出现, ( 之前都是好好的... ) [lk ] ERROR [08-12 15:10:02] [main] org.springframework.web.context.Con ...

  5. 关于xml加载提示: Error on line 1 of document : 前言中不允许有内容

    我是在java中做的相关测试, 首先粘贴下报错: 读取xml配置文件:xmls\property.xml org.dom4j.DocumentException: Error on line 1 of ...

  6. Eclipse "Unable to install breakpoint due to missing line number attributes..."

    Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统 ...

  7. Linix登录报"/etc/profile: line 11: syntax error near unexpected token `$'{\r''"

    同事反馈他在一测试服务器(CentOS Linux release 7.2.1511)上修改了/etc/profile文件后,使用source命令不能生效,让我帮忙看看,结果使用SecureCRT一登 ...

  8. [LeetCode] Line Reflection 直线对称

    Given n points on a 2D plane, find if there is such a line parallel to y-axis that reflect the given ...

  9. [LeetCode] Tenth Line 第十行

    How would you print just the 10th line of a file? For example, assume that file.txt has the followin ...

随机推荐

  1. Mac环境下SVN的配置和使用

    简单记录一下在Mac环境下,SVN的配置步骤和使用相关.(Mac自带了svn的服务器和客户端功能,简单配置一下即可使用) 一.SVN的配置方法 1. 创建一个仓库目录,比如在/Users/你的用户名 ...

  2. ACM-ICPC2018 沈阳赛区网络预赛-E-The cake is a lie

    You promised your girlfriend a rounded cake with at least SS strawberries. But something goes wrong, ...

  3. GridControl详解(八)菜单

    菜单控件 拖入窗口中 显示如下 设置popupMenu 设置barManager 设置controller 增加菜单项 弹出配置窗口 一般菜单项设置 对应属性如下: 对应事件: 选择菜单项设置 事件同 ...

  4. Spring 5.0

    Spring 5.0都有什么新功能? 1.最低要求支持JDK8+, J2EE 7+. 2.移除了一些包.类及方法. 3.核心功能加强:全面应用jdk8并兼容jdk9等. 4.SpringMVC:支持s ...

  5. Eng1—English daily notes

    English daily notes 2015年 4月 Phrases As a side note 作为附注,顺便说句题外话,和by the way意思相近,例句 As a side note, ...

  6. 【BZOJ】2154: Crash的数字表格 莫比乌斯反演

    [题意]给定n,m,求Σlcm(i,j),1<=i<=n,1<=j<=m,n,m<=10^7. [算法]数论(莫比乌斯反演) [题解] $$ans=\sum_{i\leq ...

  7. 浮动&定位

    本文地址:http://www.cnblogs.com/veinyin/p/7606652.html  浮动和定位能够让我们把一些元素放到理想的位置,当然,相比之下 float 只能浮动到左边或右边, ...

  8. 【洛谷 P3338】 [ZJOI2014]力(FFT)

    题目链接 \[\Huge{E_i=\sum_{j=1}^{i-1}\frac{q_j}{(i-j)^2}-\sum_{j=i+1}^{n}\frac{q_j}{(i-j)^2}}\] 设\(A[i]= ...

  9. HDU 2516 取石子游戏 (找规律)

    题目链接 Problem Description 1堆石子有n个,两人轮流取.先取者第1次可以取任意多个,但不能全部取完.以后每次取的石子数不能超过上次取子数的2倍.取完者胜.先取者负输出" ...

  10. Java的继承和多态

    看了博客园里面的一个文章,关于java的继承和多态: class A ...{ public String show(D obj)...{ return ("A and D"); ...