Lang:Python2
Edit123456789101112131415161718192021222324252627282930N = int(raw_input())s = []incorrect = Falseres = {}order = []for _ in range(N):f, ts, status = raw_input().split()ts = map(int, ts.split(':'))t = 3600 * ts[0] + 60 * ts[1] + ts[2]if status == 'END':if s:x = s.pop()if x[0] != f or x[1] != 'START' or x[2] > t:incorrect = Truebreakelse:res[f] = t - x[2]else:incorrect = Truebreakelse:order.append(f)s.append((f, status, t))if incorrect or len(s) != 0:print "Incorrect performance log"else:for f in order:t = res[f]print '{} {:0>2}:{:0>2}:{:0>2}'.format(f, t // 3600, (t%3600)//60, t%60)