1073 多选题常见计分法 (20 分) python(测试点2分析)
n, m = map(int, input().split())
option = ['a', 'b', 'c', 'd', 'e']
wrong = {} # 存储错误选项
ans = []
for i in range(m):
info = input().split()
ans.append(info)
for i in range(n):
stu = []
score = 0.0 # 采用浮点型,否则测试点2不通过,考虑score等于0的情况
info = input()[1:-1].split(') (')
# 处理学生成绩
for x in info:
stu.append(x.split())
for j in range(m):
# 只比较选项部分
stu_op = (stu[j][1:])
ans_op = (ans[j][3:])
# 找出不一样的选项
for op in option:
if op in stu_op and op in ans_op:
ans_op.remove(op)
stu_op.remove(op)
if not ans_op and not stu_op:
score += float(ans[j][0])
elif not stu_op and ans_op:
score += float(ans[j][0]) / 2
# 找出错误选项,并存入字典,值对应该选项次数,键为(题号,选项)
if ans_op:
for k in ans_op:
if (j + 1, k) in wrong.keys():
wrong[(j + 1, k)] += 1
else:
wrong[(j + 1, k)] = 1
if stu_op:
for k in stu_op:
if (j + 1, k) in wrong.keys():
wrong[(j + 1, k)] += 1
else:
wrong[(j + 1, k)] = 1
print(score)
if not wrong:
print("Too simple")
else:
res = []
max_x = max(wrong.values())
for k, v in wrong.items():
if v == max_x:
res.append(k)
res.sort(key=lambda x: (x[0], x[1]))
for i in res:
print('{} {}-{}'.format(max_x, i[0], i[1]))