python 1058 选择题 (20 分)

第一个测试点提示”非零返回“,其余的通过,可有大佬帮忙看一下

n,m = map(int,input().split(" "))
topic_list = []
ipt_list1 = []
ipt_list2 = []
error_list = []
for i in range(m):
    error_list.append(0)
    ipt_list1 = list(map(str,input().split(" ")))
    topic_list.append(ipt_list1)
#topic_list = [['3', '4', '2', 'a', 'c'], ['2', '5', '1', 'b'], ['5', '3', '2', 'b', 'c'], ['1', '5', '4', 'a', 'b', 'd', 'e']]
for i in range(n):
    grade = 0
    ipt_list2 = list(map(str,input().split(") (")))
    ipt_list2[0] = ipt_list2[0][1:]
    ipt_list2[-1] = ipt_list2[-1][:-1]
    for j in range(m):
        if topic_list[j][2] != ipt_list2[j][0]:
            error_list[j] += 1
            continue
        else:
            str1 = "".join((topic_list[j])[3:])
            str2 = (ipt_list2[j][1:]).replace(" ","")
            if str1 == str2:
                grade = grade + int(topic_list[j][0])
            else:
                error_list[j] += 1
    print(grade)
max_value = max(error_list)
if max_value == 0:
    print("Too simple")
else:
    print(max_value,end="")
    for i in range(m):
        if error_list[i] == max_value:
            print(" "+str(i+1),end="")

猜你喜欢

转载自blog.csdn.net/weixin_41775301/article/details/87709883