QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#655360 | #9454. String of CCPC | ucup-team004 | AC ✓ | 24ms | 3984kb | C++23 | 1.2kb | 2024-10-19 03:12:56 | 2024-10-19 03:12:56 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
void solve() {
int n;
std::cin >> n;
std::string s;
std::cin >> s;
int ans = 0;
for (int i = 0; i + 4 <= n; i++) {
ans += s.substr(i, 4) == "CCPC";
}
for (int i = 0; i <= n; i++) {
int v = 0;
for (int j = std::max(0, i - 3); j <= n - 4 && j < i; j++) {
v -= s.substr(j, 4) == "CCPC";
}
int vp = v, vc = v;
if (i >= 3) {
vc += s.substr(i - 3, 3) == "CCP";
}
if (i >= 2 && i + 1 <= n) {
vp += s.substr(i - 2, 3) == "CCC";
}
if (i >= 1 && i + 2 <= n) {
vc += s.substr(i - 1, 3) == "CPC";
}
if (i + 3 <= n) {
vc += s.substr(i, 3) == "CPC";
}
if (vp == 1 || vc == 1) {
ans++;
break;
}
}
std::cout << ans << "\n";
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
std::cin >> t;
while (t--) {
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3660kb
input:
3 3 CCC 5 CCCCP 4 CPCP
output:
1 1 1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 24ms
memory: 3984kb
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