python大佬帮忙看看 只有20 感觉没有错

P1042 [NOIP2003 普及组] 乒乓球

DennySun @ 2024-09-06 18:28:48

l=''
while True:
    l+=input()
    if 'E' in l:
        break

l=l[:l.index('E')]

hua11=[]
dui11=[]
hua21=[]
dui21=[]
h11=h21=d11=d21=0
for i in l:
    if i=='W':
        h11+=1
        h21+=1
    else:
        d11+=1
        d21+=1
    if (h11>=11 and h11-d11>=2) or (d11>=11 and d11-h11>=2):
        hua11.append(h11)
        dui11.append(d11)
        h11=d11=0
    if (h21>=21 and h21-d21>=2) or (d21>=21 and d21-h21>=2):
        hua21.append(h21)
        dui21.append(d21)
        h21=d21=0

for i,j in zip(hua11,dui11):
    print('%d:%d' % (i,j))
print('%d:%d' % (h11,d11))
print()
for i,j in zip(hua21,dui21):
    print('%d:%d' % (i,j))
print('%d:%d' % (h21,d21))    

|