#!/usr/bin/python2.7 import sys def score(pts, msg): print pts sys.stderr.write(msg + "\n") sys.exit(0) def checktime(t): (h, m, s) = map(int, t.split(':')) if 0 > m or m > 59: raise ValueError('minutes value out of bounds: ' + str(m)) if 0 > s or s > 59: raise ValueError('seconds value out of bounds: ' + str(s)) return 60 * 60 * int(h) + 60 * int(m) + int(s) fi = open(sys.argv[1], 'rt') fo = open(sys.argv[3], 'rt') cpsplit = {} # loeme sisendi; eeldame, et see on korrektne (ttime, l, x, y) = fi.readline().strip().split() (ttime, l, x, y) = (checktime(ttime), int(l), int(x), int(y)) e = int(fi.readline().strip()) for i in range(e): (s, d, t) = fi.readline().strip().split() t = checktime(t) key = s + '-' + d if key in cpsplit: if cpsplit[key] > t: cpsplit[key] = t else: cpsplit[key] = t try: (sum, finish_time, penalty, total) = fo.readline().strip().split() (sum, finish_time, penalty, total) = (int(sum), checktime(finish_time), int(penalty), int(total)) if finish_time >= ttime + 60 * l: score(0, "Incorrect solution: LATE") if sum - penalty != total: score(0, "Incorrect solution: sum - penalty != total") if (finish_time >= ttime) and ((finish_time - ttime + x) // x * y != penalty): score(0, "Incorrect solution: wrong penalty points") if (finish_time < ttime) and (penalty != 0): score(0, "Incorrect solution: wrong penalty points") prevcp = None timeused = 0 points = 0 visited = {} for path in fo.readline().strip().split(): if (prevcp is None) and (path != 'S'): score(0, "Incorrect solution: first CP is not S") if not (prevcp is None): key = prevcp + '-' + path if not (key in cpsplit): score(0, "Incorrect solution: no estimate for leg " + key) timeused += cpsplit[key] if not (path in visited): if path.isdigit(): points += int(path) // 100 visited[path] = 1 prevcp = path if (prevcp != 'F'): score(0, "Incorrect solution: last CP is not F") if (timeused != finish_time): score(0, "Incorrect solution: wrong finish time") if (sum != points): score(0, "Incorrect solution: wrong total score") score(sum, "OK") except SystemExit: pass except: score(0, "Format error") fi.close() fo.close()