QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#633994 | #9454. String of CCPC | ucup-team3510# | AC ✓ | 20ms | 3984kb | C++14 | 1.0kb | 2024-10-12 16:31:56 | 2024-10-12 16:31:56 |
Judging History
answer
#include<iostream>
using namespace std;
const char ch[4]={'C','C','P','C'};
int T,n;
char s[200010],S[200010];
inline bool calc(int n,int i)
{
if(i<1||i+3>n)
{
return 0;
}
for(int j=0;j<4;j++)
{
if(s[i+j]!=ch[j])
{
return 0;
}
}
return 1;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>T;
while(T--)
{
cin>>n>>s+1;
int cnt=0;
for(int i=1;i<=n;i++)
{
cnt+=calc(n,i);
S[i]=s[i];
}
for(int i=n+1;i<=n+6;i++)
{
S[i]=0;
}
int ans=cnt;
for(int i=0;i<=n;i++)
{
int now=cnt;
char c=s[i];
for(int j=i-2;j<=i;j++)
{
now-=calc(n,j);
}
for(int j=0;j<5;j++)
{
s[i+2+j]=S[i+1+j];
}
s[i+1]='C';
int Now=now;
for(int j=i-2;j<=i+1;j++)
{
Now+=calc(n+1,j);
}
ans=max(ans,Now);
s[i+1]='P';
Now=now;
for(int j=i-2;j<=i+1;j++)
{
Now+=calc(n+1,j);
}
ans=max(ans,Now);
for(int j=0;j<6;j++)
{
s[i+1+j]=S[i+1+j];
}
}
cout<<ans<<'\n';
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
3 3 CCC 5 CCCCP 4 CPCP
output:
1 1 1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 20ms
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