大佬求助,跟着题解写的,只过了两个#Python

P1042 [NOIP2003 普及组] 乒乓球

Porting @ 2024-11-29 17:42:20

record=input().replace('\n','')
record=record[:record.find('E')]
res=[0]*(len(record)+1)
w,l=0,0
for i in range(len(record)):
    if record[i]=='W':
        res[i]=1
    elif record[i]=='L':
        res[i]=2
for i in range(len(res)):
    if res[i]==1:
        w+=1
    if res[i]==2:
        l+=1
    if res[i]==0:
        print(f'{w}:{l}'+'\n\n',end='')
        break
    if abs(w-l)>=2:
        if w>=11 or l>=11:
            print(f'{w}:{l}'+'\n',end='')
            w=0
            l=0
w,l=0,0
for i in range(len(res)):
    if res[i]==1:
        w+=1
    if res[i]==2:
        l+=1
    if res[i]==0:
        print(f'{w}:{l}',end='')
        break
    if abs(w-l)>=2:
        if w>=21 or l>=21:
            print(f'{w}:{l}'+'\n',end='')
            w=0
            l=0

by Porting @ 2024-11-29 17:43:59

把测试点2下载下来,本地运行和题解是一样的,不知道为什么过不了QaQ


|