BNUOJ 52511 Keep In Line
队列,$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的更多相关文章
- bnuoj 4209 Triangle(计算几何)
http://www.bnuoj.com/bnuoj/problem_show.php?pid=4209 题意:如题 题解:公式直接计算,或者角平分线求交点 [code1]: #include < ...
- BNUOJ 52303 Floyd-Warshall Lca+bfs最短路
题目链接: https://www.bnuoj.com/v3/problem_show.php?pid=52303 Floyd-Warshall Time Limit: 60000msMemory L ...
- ILJMALL project过程中遇到Fragment嵌套问题:IllegalArgumentException: Binary XML file line #23: Duplicate id
出现场景:当点击"分类"再返回"首页"时,发生error退出 BUG描述:Caused by: java.lang.IllegalArgumentExcep ...
- 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 ...
- 关于xml加载提示: Error on line 1 of document : 前言中不允许有内容
我是在java中做的相关测试, 首先粘贴下报错: 读取xml配置文件:xmls\property.xml org.dom4j.DocumentException: Error on line 1 of ...
- Eclipse "Unable to install breakpoint due to missing line number attributes..."
Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统 ...
- Linix登录报"/etc/profile: line 11: syntax error near unexpected token `$'{\r''"
同事反馈他在一测试服务器(CentOS Linux release 7.2.1511)上修改了/etc/profile文件后,使用source命令不能生效,让我帮忙看看,结果使用SecureCRT一登 ...
- [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 ...
- [LeetCode] Tenth Line 第十行
How would you print just the 10th line of a file? For example, assume that file.txt has the followin ...
随机推荐
- vue 拦截器
拦截器:请求发送之前和请求返回之后的处理 使用:1.config---dev.env.js 开发环境配置 2. prod.env.js 生产 API:'http://www.wpdic.com' 3. ...
- codeblocks 设置代码自动补全
熟悉使用一些开发类IDE的朋友对代码自动补全一定印象深刻,如Visual studio,eclipse等,我们在程序中定义的那一个个超长的变量函数名只需打出几个字母就可自动补全,但是在codebloc ...
- 2017 ACM Arabella Collegiate Programming Contest(solved 11/13)
省选考前单挑做点ACM练练细节还是很不错的嘛- 福利:http://codeforces.com/gym/101350 先来放上惨不忍睹的virtual participate成绩(中间跑去食堂吃饭于 ...
- HDU 1930 CRT
也是很模板的一道题,给出一些数,分割,模数固定是4个互质的. /** @Date : 2017-09-16 23:54:51 * @FileName: HDU 1930 CRT.cpp * @Plat ...
- jQuery Mobile基本UI组件
基本页面构造 <!DOCTYPE html> <html> <head> <link rel="stylesheet" href=&quo ...
- Goolge-Guava Concurrent中的Service
最近在学习了下Google的Guava包,发现这真是一个好东西啊..由于平时也会写一些基于多线程的东西,所以特意了解了下这个Service框架.这里Guava包里的Service接口用于封装一个服务对 ...
- C/C++程序员必备的15个编辑器和集成开发环境
我们有许多的编程语言,像 Java,NET,PHP,Ruby,Perl 和 Python 等,但今天我们要讨论的是两个最古老和流行的语言的C和C++.它们都有其特殊的地方,更有效的功能和支持的工具,这 ...
- 搭建cdh单机版版本的hive所遇到的问题总汇
今天按照网上教程搭建了下 cdh 单机版的 hive 将相关配置记录下来 以便以后方便翻阅 版本 hive-0.13.1-cdh5.3.6.tar.gz 1. 直接解压 然后将 mysql驱动包 拷 ...
- Redis数据类型之列表(list)
1. 什么是列表 redis的列表使用双向链表实现,往列表中放元素的时候复杂度是O(1),但是随机访问的时候速度就不行了,因为需要先遍历到指定的位置才可以取到元素. 既然列表是使用链表实现的,那么就说 ...
- Unity MMO 参考数值
贴图格式: iOS :RGBA 32 (pvrtc 4 ) Android : RGB Compresed ETC 4 或 RGBA 32 . DrawCall: 总计Drawcall 平均 100 ...