Submission #5443504
Source Code Expand
from sys import stdin def readLines(): return [line.rstrip() for line in iter(stdin.readline, '')] def putLine(line): print(line, flush=True) def putLines(lines): for line in lines: putLine(line) def isConflict(x, b, a): # x |------| # b |- # a -| # or # b-a |------| # x[0] |- # x[1] -| # を以って時間帯の重複と判断 if (x[0] <= b and b <= x[1]): return True if (x[0] <= a and a <= x[1]): return True if (b <= x[0] and x[0] <= a): return True if (b <= x[1] and x[1] <= a): return True return False def main(lines): """ implemente concret logic """ result = [] tmp = [] carryup = (lambda h, m: (h, m) if m < 60 else (h+1, m % 60)) mod5down = (lambda h, m: carryup(h, m-(m % 5))) mod5up = (lambda h, m: carryup(h, m if m % 5 == 0 else m + (5 - (m % 5)))) tostr = (lambda h, m: "%02d%02d" % (h, m)) # "xxxx-yyyy"に5分刻みを適用し "XXXX-YYYY"に変換 for l in lines[1:]: # 前後を時、分でそれぞれ分割 [(b1, b2), (a1, a2)] = [(x[:2], x[2:]) for x in l.split("-")] # 直前への丸め (b1, b2) = mod5down(int(b1), int(b2)) # 直後への丸め (a1, a2) = mod5up(int(a1), int(a2)) tmp.append(tostr(b1, b2) + "-" + tostr(a1, a2)) # 昇順ソート tmp.sort() # 時刻をマージ t = tmp[0].split("-") result.append([t[0], t[1]]) for x in tmp[1:]: t = x.split("-") for r in result: # 重複がある場合 if isConflict(r, t[0], t[1]): # 開始は早い方 # 終了は遅い方 r[0] = min(r[0], t[0]) r[1] = max(r[1], t[1]) break # 重複なしは単純追加 result.append([t[0], t[1]]) return ["%s-%s" % (x[0], x[1]) for x in result] putLines(main(readLines()))
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | tatsuyaamasaki |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 2093 Byte |
Status | WA |
Exec Time | 2121 ms |
Memory | 236404 KB |
Judge Result
Set Name | all | ||||||
---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 100 | ||||||
Status |
|
Set Name | Test Cases |
---|---|
all | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, cho_cho_chokudai.txt, chokudai_ga_cho.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_01.txt | AC | 18 ms | 3192 KB |
00_sample_02.txt | AC | 17 ms | 3192 KB |
00_sample_03.txt | AC | 18 ms | 3192 KB |
cho_cho_chokudai.txt | AC | 180 ms | 7608 KB |
chokudai_ga_cho.txt | AC | 178 ms | 7732 KB |
test_01.txt | TLE | 2120 ms | 234612 KB |
test_02.txt | TLE | 2120 ms | 235252 KB |
test_03.txt | TLE | 2120 ms | 234356 KB |
test_04.txt | TLE | 2119 ms | 235764 KB |
test_05.txt | TLE | 2120 ms | 236404 KB |
test_06.txt | AC | 19 ms | 3188 KB |
test_07.txt | AC | 18 ms | 3192 KB |
test_08.txt | AC | 18 ms | 3192 KB |
test_09.txt | AC | 21 ms | 3192 KB |
test_10.txt | AC | 21 ms | 3192 KB |
test_11.txt | TLE | 2120 ms | 232692 KB |
test_12.txt | AC | 20 ms | 3188 KB |
test_13.txt | AC | 19 ms | 3192 KB |
test_14.txt | AC | 21 ms | 3192 KB |
test_15.txt | AC | 21 ms | 3192 KB |
test_16.txt | WA | 20 ms | 3188 KB |
test_17.txt | AC | 21 ms | 3192 KB |
test_18.txt | AC | 19 ms | 3192 KB |
test_19.txt | AC | 20 ms | 3192 KB |
test_20.txt | AC | 20 ms | 3192 KB |
test_21.txt | AC | 189 ms | 7608 KB |
test_22.txt | AC | 186 ms | 7604 KB |
test_23.txt | AC | 195 ms | 7616 KB |
test_24.txt | AC | 185 ms | 7616 KB |
test_25.txt | AC | 185 ms | 7704 KB |
test_26.txt | AC | 188 ms | 7608 KB |
test_27.txt | AC | 180 ms | 7608 KB |
test_28.txt | TLE | 2119 ms | 216396 KB |
test_29.txt | AC | 18 ms | 3192 KB |
test_30.txt | TLE | 2121 ms | 231924 KB |
test_31.txt | TLE | 2120 ms | 233716 KB |
test_32.txt | TLE | 2110 ms | 136680 KB |
test_33.txt | TLE | 2120 ms | 222296 KB |
test_34.txt | WA | 18 ms | 3192 KB |
test_35.txt | TLE | 2119 ms | 211188 KB |
test_36.txt | AC | 185 ms | 7604 KB |
test_37.txt | TLE | 2119 ms | 213332 KB |
test_38.txt | WA | 208 ms | 8380 KB |
test_39.txt | TLE | 2119 ms | 216888 KB |
test_40.txt | TLE | 2118 ms | 214480 KB |
test_41.txt | AC | 171 ms | 7616 KB |
test_42.txt | AC | 181 ms | 7708 KB |
test_43.txt | AC | 171 ms | 7608 KB |