Submission #459071


Source Code Expand

Copy
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

EPS = 1e-9

#http://www.deqnotes.net/acmicpc/2d_geometry/lines
def dot(a, b):
    return a.real * b.real + a.imag * b.imag

def cross(a, b):
    return a.real * b.imag - a.imag * b.real

def distance(a, b, c):
    if dot(b-a, c-a) <= EPS:
        return abs(c-a)
    if dot(a-b, c-b) <= EPS:
        return abs(c-b)
    return abs(cross(b-a, c-a)/(b-a))

N = n()
#arr = ln()
#a = sorted(ln())
#a = ln()

X = []
Y = []
for i in xrange(N):
    start, end = s().split()
    h, m, ms = map(lambda x: int(x.replace('.', '')), start.split(':'))
    h2, m2, ms2 = map(lambda x: int(x.replace('.', '')), end.split(':'))
    time1 = h*1000*60+m*1000+ms
    time2 = h2*1000*60+m2*1000+ms2
#    print h, m, ms, time1
#    print h2, m2, ms2, time2
#    print time2 - time1
    X.append(time1)
    Y.append(time2)

w_start = None
w_end = None

for i in xrange(N):
#    print Y[i] - X[i]
    if Y[i] < X[i]:
        if w_start is None or w_start > X[i]:
            w_start = X[i]
        if w_end is None or w_end > Y[i]:
            w_end = Y[i]
#        print 'check'
#print w_start, w_end
for i in xrange(N):
    d = 0
    if X[i] <= w_start and Y[i] >= w_end:
        d += 1000
    if w_start is None:
        print -1
    elif X[i] == w_start and Y[i] == w_end:
        print Y[i] - X[i] + 1000
    elif w_end <= X[i] <= w_start or w_end <= Y[i] <= w_start:
        print -1
    else:
        print Y[i] - X[i] + d

Submission Info

Submission Time
Task B - stepモード
User mugenen
Language Python (2.7.3)
Score 0
Code Size 2092 Byte
Status
Exec Time 93 ms
Memory 4872 KB

Test Cases

Set Name Score / Max Score Test Cases
All 0 / 50 00_corner100.txt, 00_corner101.txt, 00_corner102.txt, 00_corner103.txt, 00_corner104.txt, 00_corner105.txt, 00_corner106.txt, 00_corner107.txt, 00_corner108.txt, 00_corner109.txt, 00_corner110.txt, 00_corner111.txt, 00_corner112.txt, 00_corner113.txt, 00_corner114.txt, 00_corner115.txt, 00_corner116.txt, 00_corner117.txt, 00_corner118.txt, 00_corner119.txt, 00_corner120.txt, 00_corner121.txt, 00_corner122.txt, 00_corner123.txt, 00_example_1.txt, 00_example_2.txt, 00_example_3.txt, 00_example_4.txt, 00_manual_001.txt, 00_manual_002.txt, 00_manual_003.txt, 00_manual_004.txt, 00_manual_005.txt, 00_small_009.txt, 00_small_010.txt, 00_small_011.txt, 00_small_012.txt, 00_small_013.txt, 00_small_014.txt, 00_small_015.txt, 00_small_016.txt, 00_small_017.txt, 00_small_018.txt, 00_small_019.txt, 00_small_020.txt, 01_random_100.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_24.txt, 01_random_25.txt, 01_random_27.txt, 01_random_29.txt, 01_random_31.txt, 01_random_34.txt, 01_random_37.txt, 01_random_39.txt, 01_random_4.txt, 01_random_41.txt, 01_random_43.txt, 01_random_45.txt, 01_random_46.txt, 01_random_47.txt, 01_random_48.txt, 01_random_5.txt, 01_random_50.txt, 01_random_51.txt, 01_random_52.txt, 01_random_54.txt, 01_random_56.txt, 01_random_57.txt, 01_random_58.txt, 01_random_59.txt, 01_random_6.txt, 01_random_60.txt, 01_random_62.txt, 01_random_65.txt, 01_random_66.txt, 01_random_68.txt, 01_random_69.txt, 01_random_7.txt, 01_random_70.txt, 01_random_72.txt, 01_random_75.txt, 01_random_76.txt, 01_random_77.txt, 01_random_79.txt, 01_random_8.txt, 01_random_80.txt, 01_random_81.txt, 01_random_82.txt, 01_random_83.txt, 01_random_84.txt, 01_random_85.txt, 01_random_87.txt, 01_random_89.txt, 01_random_9.txt, 01_random_91.txt, 01_random_92.txt, 01_random_93.txt, 01_random_94.txt, 01_random_95.txt, 01_random_96.txt, 01_random_97.txt, 01_random_98.txt, 01_random_99.txt
Case Name Status Exec Time Memory
00_corner100.txt 79 ms 4804 KB
00_corner101.txt 80 ms 4812 KB
00_corner102.txt 81 ms 4808 KB
00_corner103.txt 81 ms 4808 KB
00_corner104.txt 80 ms 4804 KB
00_corner105.txt 80 ms 4812 KB
00_corner106.txt 80 ms 4808 KB
00_corner107.txt 80 ms 4800 KB
00_corner108.txt 80 ms 4808 KB
00_corner109.txt 80 ms 4800 KB
00_corner110.txt 80 ms 4808 KB
00_corner111.txt 80 ms 4800 KB
00_corner112.txt 80 ms 4804 KB
00_corner113.txt 80 ms 4804 KB
00_corner114.txt 80 ms 4796 KB
00_corner115.txt 80 ms 4808 KB
00_corner116.txt 80 ms 4804 KB
00_corner117.txt 80 ms 4808 KB
00_corner118.txt 80 ms 4804 KB
00_corner119.txt 78 ms 4808 KB
00_corner120.txt 78 ms 4808 KB
00_corner121.txt 78 ms 4812 KB
00_corner122.txt 78 ms 4812 KB
00_corner123.txt 78 ms 4748 KB
00_example_1.txt 78 ms 4812 KB
00_example_2.txt 77 ms 4804 KB
00_example_3.txt 78 ms 4804 KB
00_example_4.txt 77 ms 4816 KB
00_manual_001.txt 77 ms 4812 KB
00_manual_002.txt 76 ms 4804 KB
00_manual_003.txt 77 ms 4800 KB
00_manual_004.txt 76 ms 4796 KB
00_manual_005.txt 77 ms 4872 KB
00_small_009.txt 79 ms 4736 KB
00_small_010.txt 76 ms 4808 KB
00_small_011.txt 76 ms 4808 KB
00_small_012.txt 79 ms 4736 KB
00_small_013.txt 77 ms 4804 KB
00_small_014.txt 77 ms 4800 KB
00_small_015.txt 78 ms 4796 KB
00_small_016.txt 77 ms 4812 KB
00_small_017.txt 79 ms 4732 KB
00_small_018.txt 77 ms 4800 KB
00_small_019.txt 77 ms 4804 KB
00_small_020.txt 77 ms 4808 KB
01_random_100.txt 78 ms 4800 KB
01_random_11.txt 77 ms 4804 KB
01_random_12.txt 77 ms 4808 KB
01_random_13.txt 77 ms 4800 KB
01_random_14.txt 78 ms 4808 KB
01_random_16.txt 76 ms 4796 KB
01_random_17.txt 79 ms 4736 KB
01_random_18.txt 76 ms 4800 KB
01_random_19.txt 79 ms 4732 KB
01_random_20.txt 79 ms 4736 KB
01_random_21.txt 77 ms 4808 KB
01_random_24.txt 76 ms 4808 KB
01_random_25.txt 78 ms 4808 KB
01_random_27.txt 80 ms 4736 KB
01_random_29.txt 78 ms 4736 KB
01_random_31.txt 79 ms 4756 KB
01_random_34.txt 78 ms 4804 KB
01_random_37.txt 77 ms 4808 KB
01_random_39.txt 77 ms 4808 KB
01_random_4.txt 77 ms 4800 KB
01_random_41.txt 78 ms 4804 KB
01_random_43.txt 78 ms 4804 KB
01_random_45.txt 78 ms 4804 KB
01_random_46.txt 79 ms 4800 KB
01_random_47.txt 77 ms 4808 KB
01_random_48.txt 78 ms 4808 KB
01_random_5.txt 78 ms 4804 KB
01_random_50.txt 78 ms 4804 KB
01_random_51.txt 79 ms 4800 KB
01_random_52.txt 80 ms 4808 KB
01_random_54.txt 79 ms 4804 KB
01_random_56.txt 79 ms 4800 KB
01_random_57.txt 79 ms 4804 KB
01_random_58.txt 79 ms 4800 KB
01_random_59.txt 79 ms 4804 KB
01_random_6.txt 78 ms 4804 KB
01_random_60.txt 77 ms 4800 KB
01_random_62.txt 79 ms 4808 KB
01_random_65.txt 78 ms 4804 KB
01_random_66.txt 79 ms 4800 KB
01_random_68.txt 79 ms 4812 KB
01_random_69.txt 79 ms 4800 KB
01_random_7.txt 78 ms 4804 KB
01_random_70.txt 79 ms 4800 KB
01_random_72.txt 79 ms 4800 KB
01_random_75.txt 78 ms 4796 KB
01_random_76.txt 79 ms 4812 KB
01_random_77.txt 79 ms 4796 KB
01_random_79.txt 79 ms 4804 KB
01_random_8.txt 78 ms 4796 KB
01_random_80.txt 78 ms 4800 KB
01_random_81.txt 79 ms 4804 KB
01_random_82.txt 80 ms 4804 KB
01_random_83.txt 81 ms 4796 KB
01_random_84.txt 80 ms 4800 KB
01_random_85.txt 82 ms 4800 KB
01_random_87.txt 80 ms 4812 KB
01_random_89.txt 93 ms 4784 KB
01_random_9.txt 79 ms 4812 KB
01_random_91.txt 83 ms 4804 KB
01_random_92.txt 81 ms 4800 KB
01_random_93.txt 83 ms 4792 KB
01_random_94.txt 79 ms 4804 KB
01_random_95.txt 80 ms 4804 KB
01_random_96.txt 81 ms 4796 KB
01_random_97.txt 82 ms 4736 KB
01_random_98.txt 80 ms 4796 KB
01_random_99.txt 80 ms 4800 KB