Submission #4009935
Source Code Expand
import math class TimeHM(object): def __init__(self, hm_str, en_ceil): self. hour = int(hm_str[:2]) self. minute = int(hm_str[2:]) self.Round5(en_ceil) def Round5(self, en_ceil): if en_ceil: self.minute = int(math.ceil(self.minute / 5.0)) * 5 else: # floor self.minute = int(math.floor(self.minute / 5.0)) * 5 if self.minute >= 60: self.minute -= 60 self.hour += 1 def __eq__(self, other): return self.hour == other.hour and self.minute == other.minute def __le__(self, other): return self.hour < other.hour or (self.hour == other.hour and self.minute <= other.minute) def __lt__(self, other): return self.hour < other.hour or (self.hour == other.hour and self.minute < other.minute) def __ge__(self, other): return self.hour > other.hour or (self.hour == other.hour and self.minute >= other.minute) def __gt__(self, other): return self.hour > other.hour or (self.hour == other.hour and self.minute > other.minute) def __ne__(self, other): return not self.__eq__(other) def __str__(self): return "%02d%02d" % (self.hour, self.minute) class TimeRange(object): def __init__(self, hm_start_str, hm_end_str): self.startTime_ = TimeHM(hm_start_str, False) self.endTime_ = TimeHM(hm_end_str, True) def __str__(self): return str(self.startTime_) + "-" + str(self.endTime_) def __eq__(self, other): return self.startTime_ == other.startTime_ def __le__(self, other): return self.startTime_ <= other.startTime_ def __lt__(self, other): return self.startTime_ < other.startTime_ def __ge__(self, other): return not self.__lt__(other) def __gt__(self, other): return not self.__le__(other) def __ne__(self, other): return not self.__eq__(other) def MergeTimeRange(target_lhs, target_rhs): if target_lhs.endTime_ >= target_rhs.startTime_: if target_lhs.endTime_ >= target_rhs.endTime_: return True, TimeRange(str(target_lhs.startTime_), str(target_lhs.endTime_)) else: return True, TimeRange(str(target_lhs.startTime_), str(target_rhs.endTime_)) else: return False, None num_data = int(input()) time_range_set = [] for i in range(num_data): hm_start_str, hm_end_str = input().strip().split("-") time_range_set.append(TimeRange(hm_start_str, hm_end_str)) time_range_set.sort() #for s in time_range_set: # print(s) en_merge = len(time_range_set) > 1 while en_merge: #print("----") new_trs = [] #print(len(time_range_set)) target_lhs = time_range_set[0] i_trs = 1 while i_trs < len(time_range_set): target_rhs = time_range_set[i_trs] is_merged, new_time_range = MergeTimeRange(target_lhs, target_rhs) if is_merged: target_lhs = new_time_range else: new_trs.append(target_lhs) target_lhs = target_rhs i_trs += 1 new_trs.append(target_lhs) # the last one if len(time_range_set) == len(new_trs): # Nothing merged en_merge = False time_range_set = new_trs #for s in time_range_set: # print(s) #print("----FINAL----") for s in time_range_set: print(s)
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | glass5er |
Language | Python (3.4.3) |
Score | 100 |
Code Size | 3070 Byte |
Status | AC |
Exec Time | 723 ms |
Memory | 18332 KB |
Judge Result
Set Name | all | ||
---|---|---|---|
Score / Max Score | 100 / 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 | 17 ms | 3192 KB |
00_sample_02.txt | AC | 17 ms | 3192 KB |
00_sample_03.txt | AC | 17 ms | 3192 KB |
cho_cho_chokudai.txt | AC | 526 ms | 18204 KB |
chokudai_ga_cho.txt | AC | 513 ms | 18332 KB |
test_01.txt | AC | 19 ms | 3192 KB |
test_02.txt | AC | 19 ms | 3192 KB |
test_03.txt | AC | 19 ms | 3192 KB |
test_04.txt | AC | 19 ms | 3192 KB |
test_05.txt | AC | 19 ms | 3192 KB |
test_06.txt | AC | 22 ms | 3192 KB |
test_07.txt | AC | 20 ms | 3192 KB |
test_08.txt | AC | 19 ms | 3192 KB |
test_09.txt | AC | 30 ms | 3316 KB |
test_10.txt | AC | 31 ms | 3316 KB |
test_11.txt | AC | 27 ms | 3316 KB |
test_12.txt | AC | 26 ms | 3192 KB |
test_13.txt | AC | 22 ms | 3192 KB |
test_14.txt | AC | 29 ms | 3316 KB |
test_15.txt | AC | 31 ms | 3316 KB |
test_16.txt | AC | 21 ms | 3192 KB |
test_17.txt | AC | 29 ms | 3316 KB |
test_18.txt | AC | 22 ms | 3192 KB |
test_19.txt | AC | 26 ms | 3192 KB |
test_20.txt | AC | 27 ms | 3316 KB |
test_21.txt | AC | 700 ms | 18332 KB |
test_22.txt | AC | 700 ms | 18332 KB |
test_23.txt | AC | 699 ms | 18332 KB |
test_24.txt | AC | 701 ms | 18332 KB |
test_25.txt | AC | 697 ms | 18332 KB |
test_26.txt | AC | 723 ms | 18332 KB |
test_27.txt | AC | 594 ms | 18204 KB |
test_28.txt | AC | 700 ms | 18332 KB |
test_29.txt | AC | 18 ms | 3192 KB |
test_30.txt | AC | 18 ms | 3192 KB |
test_31.txt | AC | 118 ms | 5340 KB |
test_32.txt | AC | 18 ms | 3192 KB |
test_33.txt | AC | 461 ms | 13044 KB |
test_34.txt | AC | 17 ms | 3192 KB |
test_35.txt | AC | 23 ms | 3192 KB |
test_36.txt | AC | 716 ms | 18332 KB |
test_37.txt | AC | 711 ms | 18332 KB |
test_38.txt | AC | 714 ms | 18332 KB |
test_39.txt | AC | 680 ms | 18332 KB |
test_40.txt | AC | 668 ms | 18332 KB |
test_41.txt | AC | 523 ms | 18204 KB |
test_42.txt | AC | 688 ms | 18332 KB |
test_43.txt | AC | 534 ms | 18332 KB |