QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#706852#9454. String of CCPCpropane#AC ✓12ms4032kbC++201.2kb2024-11-03 13:42:102024-11-03 13:42:11

Judging History

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

  • [2024-11-03 13:42:11]
  • 评测
  • 测评结果:AC
  • 用时:12ms
  • 内存:4032kb
  • [2024-11-03 13:42:10]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
using LL = long long;

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    int T;
    cin >> T;
    while(T--){
        int n;
        cin >> n;
        string s;
        cin >> s;
        int cnt = 0;
        bool ok = false;
        for(int i = 0; i < n; i++){
            if (s.substr(i, 4) == "CCPC"){
                cnt += 1;
            }
        }
        for(int i = 0; i + 2 < n; i++){
            auto t = s.substr(i, 3);
            if (t == "CCC"){
                auto tt = s.substr(i + 1, 4);
                if (tt != "CCPC"){
                    ok = true;
                    break;
                }
            }
            if (t == "CPC"){
                if (i == 0 or s[i - 1] != 'C'){
                    ok = true;
                    break;
                }
            }
            if (t == "CCP"){
                if (i + 3 == n or s[i + 3] != 'C'){
                    ok = true;
                    break;
                }
            }
        }
        cout << cnt + ok << '\n';
    }

}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3844kb

input:

3
3
CCC
5
CCCCP
4
CPCP

output:

1
1
1

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 12ms
memory: 4032kb

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