QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#636767 | #9454. String of CCPC | ucup-team4810# | WA | 360ms | 11112kb | Python3 | 502b | 2024-10-13 02:41:22 | 2024-10-13 02:41:23 |
Judging History
answer
from functools import *
@lru_cache(None)
def f(l,r):
ans=0
ss=l+r
ic = sum(ss[j:j+4]=='CCPC' for j in range(3))
for nc in 'CP':
nss = l+nc+r
nic = sum(nss[j:j+4]=='CCPC' for j in range(4))
# print(ss,nss,nic,ic)
if nic>ic:
ans=max(ans,nic-ic)
return ans
def tc():
n=int(input())
s=input()
ans = 0
print(max(f(s[max(0,i-3):i],s[i:i+3]) for i in range(n+1)))
for _ in range(int(input())):
tc()
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 19ms
memory: 10528kb
input:
3 3 CCC 5 CCCCP 4 CPCP
output:
1 1 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 360ms
memory: 11112kb
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:
0 1 0 1 1 0 1 1 1 1 1 0 1 0 0 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 0 0 1 1 1 0 1 1 0 1 1 0 1 0 1 0 1 1 1 0 1 1 1 1 1 0 0 1 0 0 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 0 1 1 1 0 1 1 1 1 1 0 1 1 1 1 0 1 1 1 0 1 1 0 1 0 1 1 1 0 0 1 0 1 0 1 1 1 1 1 1 1 0 0 0 1 1 0 1 1 ...
result:
wrong answer 1st lines differ - expected: '1', found: '0'