滴答滴答---题目链接

E. Stupid Submissions

time limit per test

1.5 s

memory limit per test

256 MB

input

standard input

output

standard output

Abed is so motivated this year, his goal is qualifying for the 2019 ACM International Collegiate Programming Contest (ACM ICPC). Therefore, he always trains using Codeforces online judge. If you do not know Codeforces, the following rules can help you to understand how it works:

  • Each problem has a set of n tests numbered from 1 to n. The first k tests are called sample tests. These tests are visible in the problem statement and a user can see them all.
  • When Abed gets a wrong answer on test x (x ≤ n), he can see all the tests up to test number x. If Abed gets accepted, he can see all the tests.
  • Each test can be either small or big. Abed can see the entire test only if it is small. If the test is big, Abed can see it partially. All the sample tests are small.

For example, let us consider a problem contains 6 tests, in which the first two tests are the sample tests. If Abed got a wrong answer on test 4, a wrong answer on test 3, and a wrong answer on test 5, he can see all tests from 1 to 5. If test 3 is small and the tests from 4 to 6are big, Abed can see the first three tests fully, but he cannot fully see the remaining tests.

Unfortunately, Abed usually gets a lot of wrong answers. A submission made by Abed is called stupid if he got a wrong answer on a small test that he can see it fully. You are given a list of submissions made be Abed, your task is to count how many stupid submission Abed has made. Can you?

Input

The first line contains an integer T (1 ≤ T ≤ 100) specifying the number of test cases.

The first line of each test case contains three integers nm, and k (1 ≤ k ≤ n ≤ 104, 1 ≤ m ≤ 104), in which n is the number of tests in the problem, m is the number of submissions Abed has made, and k is the number of sample tests. Then a line follow contains n characters t1, ..., tn, in which ti is 'S' if the ith test is small, and 'B' if it is big.

Then m lines follow, giving the list of submissions Abed has made, such that the ith line will either contain a single character 'A' if Abed got accepted on the ith submission, or contain a character 'W' and an integer x (1 ≤ x ≤ n) giving that Abed got a wrong answer on test case x.

Output

For each test case, print a single line containing the number of stupid submissions Abed has made.

Example

input

Copy

2
5 4 2
S S B S B
W 3
W 4
W 4
A
4 3 2
S S B B
W 1
W 2
W 3

output

Copy

1
2
#include<bits/stdc++.h>
using namespace std;
int s[10001];
int main()
{int t;scanf("%d",&t);while(t--){int n,m,a,b;char x[5];scanf("%d%d%d",&n,&m,&a);for(int i=1; i<=n; i++){scanf("%s",x);if(x[0]=='S')s[i]=0;else s[i]=1;}int ans=0;for(int i=0; i<m; i++){scanf("%s",x);if(x[0]=='W'){scanf("%d",&b);if(s[b]==0){if(b<=a)ans++;}a=max(a,b);}else if(x[0]=='A')a=n;}printf("%d\n",ans);}return 0;
}

E. Stupid Submissions(思维)相关推荐

  1. 揭富人与穷人21个不同思维 看富豪如何脱颖而出

    <富人是怎么想的>(How Rich People Think)的作者Steve Siebold曾在近30年里采访世界各地的富豪,看究竟是什么让富豪从普通人中站出来. 他发现这和金钱基本没 ...

  2. 学习,思维三部曲:WHAT、HOW、WHY

    学习技术的三部曲:WHAT HOW WHY 我把学习归类为三个步骤:What.How.Why.经过我对周围同事和朋友的观察,大部分感觉自己技术没有提高的人,都仅仅停留在What阶段.下面我把这三个步骤 ...

  3. Linux架构思维导图

    Linux架构思维导图 GUI(Graphical User Interface,图形用户界面) Linux 学习路径 软件框架 Linux 桌面介绍 FHS:文件系统目录标准 Linux 需要特别注 ...

  4. github 思维导图开元软件_画思维导图记笔记的工具软件

    思维导图是很多人在做笔记的时候都会用到的一种记录方式,使用思维导图可以简单有效的表达发散性思维,能够协助人们在各种因素间平衡展开思考,从而提升自己笔记的含金量和工作效率,有没有画思维导图记笔记的工具软 ...

  5. 大数据概念思维导图_思维导图|数据化风控(信用评分建模教程)

    本文将按<数据化风控--信用评分建模教程>行文逻辑,并结合相关参考材料,为大家梳理本书涉及的重点知识,也算是自己读书笔记分享.有需要的同学可先收藏.点赞,以便回顾学习和吸收,当然,如果愿意 ...

  6. puml绘制思维导图_如何用ProcessOn画出漂亮的思维导图

    说到绘制思维导图,很多人可能都知道XMind,但不一定了解ProcessOnProcessOn - 免费在线作图,实时协作,总以为后者绘制流程图很强大,殊不知其在思维导图方面也有很强大的功能. 好工具 ...

  7. 计算机思维采用抽象和分解,凤凰机器人----什么是计算思维?凤凰机器人的编程课中是如何体现它的?...

    对于生活在科技和智能自动化时代的孩子们来说,理解计算机的思维方式,运用计算思维去解决生活中的问题,被认为和听.说.读.写.算一样,是每个人必备的思维能力.然而,到底什么才是计算思维呢? 计算思维是一种 ...

  8. tp3 普通模式url模式_《终身成长》:三个步骤打造成长型思维模式,普通人也可以成功...

    罗伯特很小是一个聪明的孩子,父母以他为傲,经常夸奖他,对他表达爱.结果他没有考上一个纽约第1名的幼儿园,父母就不像以前那样对他了,不会再经常表达爱,夸奖他,对他就越来越冷淡,他在父母眼里是一个失败者, ...

  9. 大学计算机思维导图_我学计算机,也会修电脑

    "你学啥专业?" "计算机科学." "帮我修电脑吧." "--" 现实中-- 金融专业的被问炒股 土木专业的被问装修 天 ...

最新文章

  1. 【廖雪峰Python学习笔记】字符串与编码
  2. 暴力枚举 UVA 725 Division
  3. c语言测试代码怎么写,初学C语言,写了一个测试手速的工具,代码发上来,存着。。...
  4. 科研人员请注意!腾讯要为你们专项开放数据、计算资源、实验环境
  5. liunxC下零碎知识点的总结
  6. 如何优雅的使用 phpStorm
  7. 深度学习之PyTorch物体检测实战——新书赠送活动
  8. UITabBarController加载之后不显示sub view controller
  9. 设计模式之Observer(观察者)模式
  10. 关系抽取---(二)卷积神经网络
  11. 五步法建设你的数据中台
  12. Oracle解决Ora-01653无法扩展表空间问题
  13. 动手教你撸一个iOS颜色拾取器
  14. 使用3CDaemon 进行ftp 传输文件 (linux-开发板) 的方法
  15. 生成pdf设置中文字体出错Identity-H' is not recognized
  16. python爬虫网页脚本_python网络爬虫之Scrapy
  17. 安卓毕业设计选题基于Uniapp实现的Android的校园二手商品交易平台
  18. Oracle中的sql语句
  19. python xlwt安装linux_Linux安装Python xlrd、xlwt、xlutils模块
  20. 云主机安装redis

热门文章

  1. elementUI表格气泡乱串、闪烁、位置偏移问题解决(自制气泡,计算位置,箭头永远指向当前元素)
  2. html跳动的心,css3跳动的心制作
  3. FloorPlan 经验总结
  4. 20句黑客经典语录,一个黑客的内心独白
  5. 地图制作|AI编辑标准地图,制作符合出版需要的地图文件
  6. java流程控制原理与方法_1.从本质上看,计算机控制系统的工作原理可归纳为三个步骤,以下不属这三个步骤的是 ( )。_学小易找答案...
  7. VUE2.0实现 高德地图 选择地点后 进行 行政区边界划分
  8. php百度地图接口两点测距,百度地图Api 根据两个坐标点计算距离
  9. MySQL常见错误码
  10. 随心玩玩(三)Mirai框架QQ机器人