队列,$map$。

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

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int T,n,sz,sum;
  4. int f[];
  5. char op[];
  6. int main()
  7. {
  8. scanf("%d",&T);
  9. while(T--)
  10. {
  11. scanf("%d",&n); sum=sz=;
  12. map<string,int>zhuan;
  13. queue<int>Q;
  14. memset(f,,sizeof f);
  15. for(int i=;i<=n;i++)
  16. {
  17. scanf("%s",op);
  18. if(op[]=='i')
  19. {
  20. scanf("%s",op);
  21. zhuan[op]=++sz;
  22. Q.push(sz);
  23. }
  24. else
  25. {
  26. while()
  27. {
  28. if(Q.empty()) break;
  29. if(f[Q.front()]==) break;
  30. Q.pop();
  31. }
  32. scanf("%s",op);
  33. int id = zhuan[op];
  34. f[id]=;
  35. if(Q.front()!=id) sum++;
  36. }
  37. }
  38. printf("%d\n",n/-sum);
  39. }
  40. return ;
  41. }

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. spring整合hibernate时报错:org.hibernte.engine.transaction.spi.transactioncontext

    错误提示:Caused by:java.lang.ClassNotFoundException: org.hibernte.engine.transaction.spi.transactioncont ...

  2. 数据分析与展示---anaconda的使用

    一:安装 官方源:https://repo.continuum.io/archive/(太慢) 清华源:https://mirrors.tuna.tsinghua.edu.cn/anaconda/ar ...

  3. JS-this的用法

    o.onclick=function(){alert(this)}//这个this是指o ------ var arr=[1,2,3,4,5]; arr.a=12; arr.show=function ...

  4. Atcoder arc077 D - 11 组合

    Link 题意:给出n个数,其中有一个数会出现两次,其余数只出现一次,问不同长度且不同的子串的数量.取模1e9+7 思路:组合求出所有情况,减去重复情况,注意用逆元即可 /** @Date : 201 ...

  5. 2015/10/9 Python核编初级部分学习总结

    终于在十一长假之后的两天看完了<Python核心编程>的初级部分.虽然到后来两章,类和环境看得越来越慢,越来越难以理解.很多东西只能靠强记,也没办法真正掌握了,我想了想,还是不强迫自己去背 ...

  6. 关于static关键字

    static用于修饰成员(成员变量,成员函数),不能修饰局部变量被修饰的变量和函数是静态的,可被多个对象共享,节省内存可以直接被类名调用++++++++++++++++++++++++++++++++ ...

  7. Hadoop 面试总结

    1.简要描述如何安装配置一个开源的hadoop,只描述即可,列出完整步骤. a.创建一个用户和用户组,用来管理hadoop项目 b.修改确定ip地址:vim /etc/sysconfig/networ ...

  8. 【AtCoder】ARC092 D - Two Sequences

    [题目]AtCoder Regular Contest 092 D - Two Sequences [题意]给定n个数的数组A和数组B,求所有A[i]+B[j]的异或和(1<=i,j<=n ...

  9. idea docker 连接 linux 上的 docker

    安装插件 Docker插件,首先需要在你的IDEA中安装Docker插件,定位到File-Setting-Plugins后搜索Docker Integration安装 配置Docker服务器,在IDE ...

  10. 36 - 网络编程-TCP编程

    目录 1 概述 2 TCP/IP协议基础 3 TCP编程 3.1 通信流程 3.2 构建服务端 3.3 构建客户端 3.4 常用方法 3.4.1 makefile方法 3.5 socket交互 3.4 ...