提交时间:2025-06-02 20:07:19
运行 ID: 325158
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)}")