n | import numpy as np | n | |
| import datetime as dt | | import datetime as dt |
n | from operator import itemgetter, attrgetter | n | from operator import itemgetter |
| | | |
n | def conv(str): | n | def to_time(str): |
| date_time_str = str | | date_time_str = str |
| date_time_obj = dt.datetime.strptime(date_time_str, '%H:%M:%S') | | date_time_obj = dt.datetime.strptime(date_time_str, '%H:%M:%S') |
| return date_time_obj.time() | | return date_time_obj.time() |
n | (maxlenname, maxlenfam, maxlenteam, maxlentime) = (0, 0, 0, 0) | n | (NameLenMax, FamLenMax, TeamLenMax, TimeLenMaxe) = (0, 0, 0, 0) |
| | | |
n | def pars(str): | n | def add_person(str): |
| lst = str.split(' ') | | cur_ch = str.split(' ') |
| name = lst[0] | | name = cur_ch[0] |
| family = lst[1] | | family = cur_ch[1] |
| team = ' '.join(lst[2:len(lst) - 1]) | | team = ' '.join(cur_ch[2:len(cur_ch) - 1]) |
| time = lst[-1] | | time = cur_ch[-1] |
| return (name, family, team, conv(time)) | | return (name, family, team, to_time(time)) |
| | | |
n | def conv2(str): | n | def to_time2(str): |
| newstr = '' | | newstr = '' |
| for i in range(0, len(str)): | | for i in range(0, len(str)): |
| if str[i] == '0' and i in [0, 3, 6]: | | if str[i] == '0' and i in [0, 3, 6]: |
| continue | | continue |
| else: | | else: |
| newstr += str[i] | | newstr += str[i] |
| return newstr | | return newstr |
| | | |
n | def maxels(matr): | n | def max_of_elements(a): |
| global maxlenname, maxlenfam, maxlenteam, maxlentime | | global NameLenMax, FamLenMax, TeamLenMax, TimeLenMaxe |
| for lst in matr: | | for cur_ch in a: |
| name = lst[0] | | name = cur_ch[0] |
| if maxlenname < len(name): | | if NameLenMax < len(name): |
| maxlenname = len(name) | | NameLenMax = len(name) |
| family = lst[1] | | family = cur_ch[1] |
| if maxlenfam < len(family): | | if FamLenMax < len(family): |
| maxlenfam = len(family) | | FamLenMax = len(family) |
| team = lst[2] | | team = cur_ch[2] |
| if maxlenteam < len(team): | | if TeamLenMax < len(team): |
| maxlenteam = len(team) | | TeamLenMax = len(team) |
| time = lst[-1].strftime('%H:%M:%S') | | time = cur_ch[-1].strftime('%H:%M:%S') |
| if maxlentime < len(time): | | if TimeLenMaxe < len(time): |
| maxlentime = len(time) | | TimeLenMaxe = len(time) |
| str = input() | | str = input() |
n | matr = [] | n | a = [] |
| while str: | | while str: |
n | matr.append(pars(str)) | n | a.append(add_person(str)) |
| str = input() | | str = input() |
n | res = sorted(matr, key=itemgetter(-1, 1, 0, 2)) | n | res = sorted(a, key=itemgetter(-1, 1, 0, 2)) |
| if len(res) <= 2: | | if len(res) <= 2: |
n | col = len(res) | n | kol = len(res) |
| else: | | else: |
n | col = 1 | n | kol = 1 |
| reit = 0 | | rt = 0 |
| for i in range(len(res) - 1): | | for i in range(len(res) - 1): |
| if res[i][-1] == res[i + 1][-1]: | | if res[i][-1] == res[i + 1][-1]: |
n | col += 1 | n | kol += 1 |
| else: | | else: |
n | reit += 1 | n | rt += 1 |
| if reit == 3: | | if rt == 3: |
| break | | break |
t | col += 1 | t | kol += 1 |
| maxels(res[:col + 1]) | | max_of_elements(res[:kol + 1]) |
| for i in range(col): | | for i in range(kol): |
| print(res[i][0].ljust(maxlenname), end=' ') | | print(res[i][0].ljust(NameLenMax), end=' ') |
| print(res[i][1].ljust(maxlenfam), end=' ') | | print(res[i][1].ljust(FamLenMax), end=' ') |
| print(res[i][2].ljust(maxlenteam), end=' ') | | print(res[i][2].ljust(TeamLenMax), end=' ') |
| print(conv2(res[i][-1].strftime('%H:%M:%S')), end='') | | print(to_time2(res[i][-1].strftime('%H:%M:%S')), end='') |
| print() | | print() |