QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#634108 | #9454. String of CCPC | ucup-team4967# | AC ✓ | 33ms | 3740kb | C++17 | 1.0kb | 2024-10-12 16:43:07 | 2024-10-12 16:43:14 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
#define MOD (ll)998244353
ll solve(ll n){
string s;
cin >> s;
ll cnt = 0;
bool ok = false;
REP(i, n - 3){
if(s[i] == 'C' and s[i + 1] == 'C' and s[i + 2] == 'P' and s[i + 3] == 'C') cnt++;
if(s[i] == 'C' and s[i + 1] == 'C' and s[i + 2] == 'P' and s[i + 3] != 'C') ok = true;
if(s[i] != 'C' and s[i + 1] == 'C' and s[i + 2] == 'P' and s[i + 3] == 'C') ok = true;
if(s[i] == 'C' and s[i + 1] == 'C' and s[i + 2] == 'C' and s[i + 3] != 'P') ok = true;
}
REP(i, n - 2){
if(s[i] == 'C' and s[i + 1] == 'C' and s[i + 2] == 'C') {
if(!(i + 4 < n and s[i + 3] == 'P' and s[i + 4] == 'C')) ok = true;
}
}
if(n >= 3 and s[0] == 'C' and s[1] == 'P' and s[2] == 'C') ok = true;
if(n >= 3 and s[n - 3] == 'C' and s[n - 2] == 'C' and s[n - 1] == 'P') ok = true;
return (ok ? cnt + 1 : cnt);
}
int main() {
ll ttt;
cin >> ttt;
REP(tt, ttt){
ll n;
cin >> n;
cout << solve(n) << endl;
}
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3544kb
input:
3 3 CCC 5 CCCCP 4 CPCP
output:
1 1 1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 33ms
memory: 3740kb
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