QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#633974 | #9454. String of CCPC | ucup-team4906# | AC ✓ | 59ms | 3852kb | C++17 | 1.2kb | 2024-10-12 16:30:12 | 2024-10-12 16:30:19 |
Judging History
answer
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
string s, t;
int n;
int calc()
{
int m = t.length();
int sum = 0;
for (int i = 0; i < m - 3; i ++)
{
if (t[i] == 'C' && t[i + 1] == 'C' && t[i + 2] == 'P' && t[i + 3] == 'C')
{
sum ++;
}
}
return sum;
}
const int D = 10;
void sol()
{
cin >> n;
cin >> s;
t = s;
int ans = calc();
for (int i = 0; i <= n; i ++)
{
t = "";
for (int j = max(0, i - D); j < min(i + D, n); j ++) t += s[j];
int v1 = calc();
t = "";
for (int j = max(0, i - D); j < i; j ++)t += s[j];
t += 'C';
for (int j = i; j < min(i + D, n); j ++)t += s[j];
int v2 = calc();
t = "";
for (int j = max(0, i - D); j < i; j ++)t += s[j];
t += 'P';
for (int j = i; j < min(i + D, n); j ++)t += s[j];
int v3 = calc();
if (max(v3, v2) > v1) {ans ++; break;}
}
cout << ans << '\n';
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int T = 1;
cin >> T;
while (T --) sol();
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
3 3 CCC 5 CCCCP 4 CPCP
output:
1 1 1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 59ms
memory: 3852kb
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