QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#632452#9454. String of CCPCucup-team4474#AC ✓13ms4236kbC++201.4kb2024-10-12 13:25:212024-10-12 13:25:27

Judging History

你现在查看的是最新测评结果

  • [2024-10-12 13:25:27]
  • 评测
  • 测评结果:AC
  • 用时:13ms
  • 内存:4236kb
  • [2024-10-12 13:25:21]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

bool Memory_begin;

/**/

bool Memory_end;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cerr << (&Memory_end - &Memory_begin) / 1048576.0 << "MB" << '\n';

    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        string s;
        cin >> s;
        int ans = 0;
        for (int i = 3; i < s.length(); i++)
            ans += (s.substr(i - 3, 4) == "CCPC");
        auto go = [&]() -> void
        {
            for (int i = 2; i < s.length(); i++)
            {
                if (s.substr(i - 2, 3) == "CPC" and (i == 2 or s[i - 3] == 'P'))
                {
                    ans += 1;
                    return;
                }
            }
            for (int i = 2; i < s.length(); i++)
            {
                if (s.substr(i - 2, 3) == "CCP" and (i + 1 == s.length() or s[i + 1] == 'P'))
                {
                    ans += 1;
                    return;
                }
            }
            for (int i = 2; i < s.length(); i++)
            {
                if (s.substr(i - 2, 3) == "CCC" and
                    (i + 2 >= s.length() or (s[i + 1] != 'P' and s[i + 2] != 'C')))
                {
                    ans += 1;
                    return;
                }
            }
        };
        go();
        cout << ans << '\n';
    }
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3692kb

input:

3
3
CCC
5
CCCCP
4
CPCP

output:

1
1
1

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 13ms
memory: 4236kb

input:

20003
5
PCCPC
10
CPPPPCPCPC
4
CPPC
11
CCPPCPPPCCP
17
PPPPCPCCCCCPCCCCC
10
PPCCPCPPCP
9
CPCCCCPPC
11
PCPPPPCCPPP
15
CPCPPPPCCPCPCCC
11
PCCPPCCPCPP
9
PCPCCPPCP
10
CCPCPPPCPP
14
CCCCPPPCPCPCPP
2
CC
12
CCPCPPPPPCPP
6
CPPPPP
12
PCCPCCCCCPCC
16
CPCCPCCPPCCCCPPC
7
CPPPCPC
16
PPPPPCCPCPCPCPPC
13
PPPCPCCCCPP...

output:

1
1
0
1
2
1
1
1
2
2
1
1
1
0
1
0
3
2
1
2
1
2
2
0
1
2
3
1
1
3
1
2
2
1
0
0
0
3
1
0
0
1
1
2
0
1
1
0
1
2
0
1
0
1
0
3
1
1
0
2
1
3
2
2
0
2
2
0
0
2
1
1
3
3
1
3
1
2
0
1
1
0
1
2
2
1
1
2
1
3
1
1
3
1
2
2
0
1
0
3
0
1
1
2
2
0
2
1
1
2
2
0
3
1
1
1
1
2
1
2
0
1
1
0
3
0
3
1
1
0
0
1
0
3
0
1
1
1
1
2
2
1
1
0
0
1
2
0
1
2
...

result:

ok 20003 lines

Extra Test:

score: 0
Extra Test Passed