Stupid Submissions(模拟)

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 6 are 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 n, m, and k (1 ≤ k ≤ n ≤ 10^4, 1 ≤ m ≤ 10^4), 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

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

1
2
n是测试点数,m是提交数,k是测试样例数(即前几个能看到)
如果测试样例错了或者S测试点错过又错,则愚蠢值+1

#include <iostream>
#include <cstdio>
using namespace std;
const int maxn=1e4+5;
int mp[maxn],vis[maxn];
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        int n,m,k,maxx;
        scanf("%d%d%d",&n,&m,&k);
        maxx=k;
        for(int i=0;i<=n;i++)
            mp[i]=0;
        getchar();
        for(int i=1;i<=n;i++)
        {
            char c;
            scanf("%c",&c);
            getchar();
            if(c=='S')
                mp[i]=1;
            else
                mp[i]=0;
        }
        int ans=0;
        for(int i=0;i<m;i++)
        {
            char c;
            scanf("%c",&c);
            getchar();
            if(c=='A')
            {
                maxx=n;
                continue;
            }
            else
            {
                int id;
                scanf("%d",&id);
                getchar();
                if(id<=maxx)
                    ans+=mp[id];
                maxx=max(maxx,id);
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值