Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
325158 | 方相宜 | 【C5-9】生日相同 | Python3 | 通过 | 100 | 68 MS | 3864 KB | 1128 | 2025-06-02 20:07:19 |
n = int(input()) students = [] for _ in range(n): parts = input().split() name = parts[0] month = int(parts[1]) day = int(parts[2]) students.append((month, day, name)) # 按月份、日期和名字排序(名字排序先按长度,再按字典序) students.sort(key=lambda x: (x[0], x[1], len(x[2]), x[2])) current_month = None current_day = None current_group = [] groups = [] for s in students: month, day, name = s if month != current_month or day != current_day: if current_group and len(current_group) >= 2: groups.append((current_month, current_day, current_group)) current_month, current_day = month, day current_group = [name] else: current_group.append(name) # 检查最后一组 if current_group and len(current_group) >= 2: groups.append((current_month, current_day, current_group)) # 按日期排序 groups.sort(key=lambda x: (x[0], x[1])) if not groups: print("None") else: for group in groups: month, day, names = group print(f"{month} {day} {' '.join(names)}")