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