QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#639999#9454. String of CCPCrogi52AC ✓28ms3932kbC++201.4kb2024-10-14 01:26:292024-10-14 01:26:30

Judging History

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

  • [2024-10-14 01:26:30]
  • 评测
  • 测评结果:AC
  • 用时:28ms
  • 内存:3932kb
  • [2024-10-14 01:26:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define srep(i, s, t) for(int i = (s); i < (t); i++)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
template < class T > bool chmin(T& a, T b) { if(a > b) { a = b; return true; } return false; }
template < class T > bool chmax(T& a, T b) { if(a < b) { a = b; return true; } return false; }
using i64 = long long;
using f64 = long double;
i64 floor_div(const i64 n, const i64 d) { assert(d != 0); return n / d - static_cast<i64>((n ^ d) <  0 && n % d != 0); }
i64  ceil_div(const i64 n, const i64 d) { assert(d != 0); return n / d + static_cast<i64>((n ^ d) >= 0 && n % d != 0); }

int solve() {
    int n; cin >> n;
    string s; cin >> s;

    s = "XXXXX" + s + "XXXXX";

    int cnt = 0, f = 0;
    for(int i = 5; i <= n + 5; i++) {
        if(s.substr(i, 4) == "CCPC") {
            cnt++;
        } else {
            if(s.substr(i, 3) == "CCC") {
                if(s.substr(i, 5) == "CCCPC");
                else f = 1;
            }
            if(s.substr(i, 3) == "CCP") f = 1;
            if(s.substr(i, 3) == "CPC") {
                if(s.substr(i - 1, 4) == "CCPC");
                else f = 1;
            }
        }
    }
    return cnt + f;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    
    int T; cin >> T;
    rep(_, T) cout << solve() << "\n";
}

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

详细

Test #1:

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

input:

3
3
CCC
5
CCCCP
4
CPCP

output:

1
1
1

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 28ms
memory: 3932kb

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