python求助

P1042 [NOIP2003 普及组] 乒乓球

DY_G @ 2024-07-22 10:13:46

m=''

while 1:

k=input()
m+=k+'\n'
if k[-1]=="E":break

w=0; l=0

for c in m:

if c=="\n":continue
if c=="E":print("%d:%d\n"%(w,l));break
if c=="W":w+=1;
else:l+=1;
if ((w==11)&(l<=9))|((l==11)&(w<=9))|((w>=10)&(l>=10)&(abs(w-l)==2)):
    print("%d:%d"%(w,l));w=0;l=0;continue

w=0;l=0

for c in m:

if c=="\n":continue
if c=="E":print("%d:%d\n\n"%(w,l));break
if c=="W":w+=1
else:l+=1
if ((w==21)&(l<=19))|((l==21)&(w<=19))|((w>=20)&(l>=20)&(abs(w-l)==2)):
    print("%d:%d"%(w,l));w=0;l=0;continue

|