求助 为什么python这段代码洛谷平台全RE
查看原帖
求助 为什么python这段代码洛谷平台全RE
1096911
abc1067899369楼主2024/11/22 10:56

自己在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)

2024/11/22 10:56
加载中...