队列,$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. LeetCode-Max Points on a Line[AC源码]

    package com.lw.leet3; import java.util.HashMap; import java.util.Iterator; import java.util.Map; imp ...

  2. 2017北京国庆刷题Day1 morning

    期望得分:100+100+100=300 实际得分:100+100+70=270 T1位运算1(bit) Time Limit:1000ms   Memory Limit:128MB 题目描述 LYK ...

  3. 通过删除hbase表中的region来达到删除表中数据

    公司最近在搞一个hbase删除数据,由于在建表的时候是通过region来对每日的数据进行存储的,所以要求在删除的时候直接通过删除region的来删除数据(最好的方案是只删除region中的数据,不把r ...

  4. 59、有用过with statement吗?它的好处是什么?

    python中的with语句是用来干嘛的?有什么作用? with语句的作用是通过某种方式简化异常处理,它是所谓的上下文管理器的一种 用法举例如下: with open('output.txt', 'w ...

  5. jq时间日期插件的使用-datetimepicker

    分三步  首先引入各种包 然后搞哥容器用id  然后加入一段js 实例: 下载:http://files.cnblogs.com/files/wordblog/datetimepicker-maste ...

  6. Coursera在线学习---第二节.Octave学习

    1)两个矩阵相乘 A*B 2)两个矩阵元素位相乘(A.B矩阵中对应位置的元素相乘) A.*B 3)矩阵A的元素进行平方 A.^2 4)向量或矩阵中的元素求倒数 1./V    或   1./A 5) ...

  7. 导航狗IT周报第十五期(July 8, 2018)

    摘要:Seclists.Org: 微信支付SDK存在XXE漏洞:WordPress 4.9.6存在文件删除漏洞:linux中常用的文件打包/解包与压缩/解压缩命令总结… 安全播报 Seclists.O ...

  8. Python 库汇总英文版

    Awesome Python  A curated list of awesome Python frameworks, libraries, software and resources. Insp ...

  9. AspNet Core 发布到Linux系统和发布IIS 注意项

    AspNet Core 发布到Linux系统和发布IIS 注意项 1.发布时需要注意的 2.Windows Server 2012 api-ms-win-crt-runtime-l1-1-0.dll ...

  10. JSP、EL表达式、JSTL

    JSP 1.什么是jsp? Java Server Pages: java服务器端页面.可以理解为一个特殊的页面,其中既可以指定定义html标签,又可以定义java代码.其本质就是一个Servlet. ...