QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#636767#9454. String of CCPCucup-team4810#WA 360ms11112kbPython3502b2024-10-13 02:41:222024-10-13 02:41:23

Judging History

你现在查看的是最新测评结果

  • [2024-10-13 02:41:23]
  • 评测
  • 测评结果:WA
  • 用时:360ms
  • 内存:11112kb
  • [2024-10-13 02:41:22]
  • 提交

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'