求助 为什么python这段代码洛谷平台全RE

P1042 [NOIP2003 普及组] 乒乓球

abc1067899369 @ 2024-11-22 10:56:39

自己在pycharm上运行样例可以通过 但是在洛谷上提交全是RE 且时间都是0ms

def score1(list1):
    flag = 0
    while flag < len(list1):
        your_score = 0
        opponent_score = 0
        if flag + 11 < len(list1):
            for i in range(flag, flag + 11):
                if list1[i] == 'W':
                    your_score += 1
                if list1[i] == 'L':
                    opponent_score += 1
            flag += 11
        else:
            for i in range(flag, len(list1) - 1):
                if list1[i] == 'W':
                    your_score += 1
                if list1[i] == 'L':
                    opponent_score += 1
            flag += 11
        print(your_score, ":", opponent_score)

def score2(list1):
    flag = 0
    while flag < len(list1):
        your_score = 0
        opponent_score = 0
        if flag + 21 < len(list1):
            for i in range(flag, flag + 21):
                if list1[i] == 'W':
                    your_score += 1
                if list1[i] == 'L':
                    opponent_score += 1
            flag += 21
        else:
            for i in range(flag, len(list1) - 1):
                if list1[i] == 'W':
                    your_score += 1
                if list1[i] == 'L':
                    opponent_score += 1
            flag += 21
        print(your_score, ":", opponent_score)

list1 = []
while True:
    line = input()
    for i in line:
        list1.append(i)
    num = len(list1)
    if list1[num - 1] == 'E':
        break

score1(list1)
print()
score2(list1)

by wwwop @ 2024-11-22 11:24:45

EOF


by farfarqwq @ 2024-11-22 11:27:40

https://blog.csdn.net/qq_35793358/article/details/77506726


|