-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProblem-3.py
53 lines (45 loc) · 1.79 KB
/
Problem-3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
def time_convert(time):
if (time[6:]=="AM"):
if (time[:2]=="12"):
return ([0,int(time[3:5])])
else:
return ([int(time[:2]),int(time[3:5])])
else:
if (time[:2]=="12"):
return ([int(time[:2]),int(time[3:5])])
else:
return ([int(time[:2])+12,int(time[3:5])])
t=int(input())
ans=[]
for i in range(t):
time_to_check=input()
time_to_check=time_convert(time_to_check)
n=int(input())
temp=""
for y in range(n):
l=input()
time_start=l[0:8]
time_end=l[9:]
time_start=time_convert(time_start)
time_end=time_convert(time_end)
if (time_start[0]>time_end[0] or (time_start[0]==time_end[0] and time_start[1]>time_end[1])):
if (time_to_check[0]<time_end[0] or time_to_check[0]>time_start[0] ):
temp=temp+"1"
elif(time_to_check[0]>time_end[0] and time_to_check[0]<time_start[0] ):
temp=temp+"0"
elif((time_to_check[0]==time_end[0] and time_to_check[1]<=time_end[1]) or (time_to_check[0]==time_start[0] and time_to_check[1]>=time_end[1])) :
temp=temp+"1"
else:
temp=temp+"0"
else:
if (time_to_check[0]<time_start[0] or time_to_check[0]>time_end[0] ):
temp=temp+"0"
elif(time_to_check[0]>time_start[0] and time_to_check[0]<time_end[0] ):
temp=temp+"1"
elif((time_to_check[0]==time_start[0] and time_to_check[1]<time_start[1]) or (time_to_check[0]==time_end[0] and time_to_check[1]>time_end[1])) :
temp=temp+"0"
else:
temp=temp+"1"
ans.append(temp)
for i in ans:
print(i)