if name == "main":
print("=== 参赛座位分配系统 ===")
teams, classrooms = input_parameters()

try:
total_seats = sum(c.rows*c.cols for c in classrooms)
total_players = sum(t.size for t in teams)
if total_seats < total_players:
raise RuntimeError(f"座位不足!总座位数:{total_seats},需要座位数:{total_players}")

allocate_seats(teams, classrooms)

# 打印所有教室布局
for c in classrooms:
c.print_layout()

# 打印详细分配结果
print("\n=== 详细分配结果 ===")
for t in teams:
print(f"\n队伍 T{t.id}({t.size}人):")
for cid in t.allocations:
entries = t.allocations[cid]
print(f" 教室{cid}:")
for (pos, identifier) in entries:
print(f" 座位{pos} -> {identifier}")

except Exception as e:
print("\n发生错误:", str(e))
 
 
Back to Top