乒乓球(python3做法)

乒乓球(python3做法)_第1张图片
乒乓球(python3做法)_第2张图片

#encoding:utf-8

lst = []
lst1 = []
s = 0
while True:
    lst1 = list(input())
    for i in lst1:
        if i != 'E':
            lst.append(i)
        else:
            s = 1
            break
    if s == 1:
        break

a, b = 0, 0
for i in lst:
    if i == 'W':
        a = a + 1
    if i == 'L':
        b = b + 1
    if (a >= 11 or b >= 11) and (a - b >= 2 or b - a >= 2):
        print("%d:%d"%(a, b))
        a, b, s1 = 0, 0, 1
        continue

if a > 0 or b > 0:
    print("%d:%d"%(a, b))
if a == 0 and b == 0:
    print("0:0")
print()

a, b = 0, 0
for i in lst:
    if i == 'W':
        a = a + 1
    if i == 'L':
        b = b + 1
    if (a >= 21 or b >= 21) and (a - b >= 2 or b - a >= 2):
        print("%d:%d"%(a, b))
        a, b= 0, 0
        continue

if a > 0 or b > 0:
    print("%d:%d"%(a, b))
if a == 0 and b == 0:
    print("0:0")

你可能感兴趣的:(acm)