QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#674384 | #9454. String of CCPC | ucup-team1338# | WA | 11ms | 4260kb | C++20 | 795b | 2024-10-25 15:29:54 | 2024-10-25 15:29:54 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
int vis[maxn];
void solve(){
int n;
string s;
cin>>n>>s;
vector<int>cc;
for(int i=0,c=0;i<n;i++) {
if(s[i]=='C')c++;
else cc.push_back(c),c=0;
if(i==n-1)cc.push_back(c);
}
int f=0;
if(cc.size()==1&&cc[0]>=3)f=1;int ans=0;
for(int i=0;i+1<cc.size();i++) {
if(cc[i]>=2&&cc[i+1]>=1)ans++;
if(cc[i]>=4) {
f=1;
}
if(cc[i+1]==0&&cc[i]>=2)f=1;
if(cc[i]==1&&cc[i+1]>=1)f=1;
}
cout<<f+ans<<'\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int T;
cin>>T;
while(T--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
input:
3 3 CCC 5 CCCCP 4 CPCP
output:
1 1 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 11ms
memory: 4260kb
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 1 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 0 3 1 2 2 0 1 0 3 0 1 1 1 2 0 2 1 1 2 2 0 3 1 1 1 1 1 1 1 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:
wrong answer 22nd lines differ - expected: '2', found: '1'