-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPYKT076 - DANH SÁCH PHIM
56 lines (54 loc) · 1019 Bytes
/
PYKT076 - DANH SÁCH PHIM
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
54
import functools
class film:
def __init__(self,ed,typ,day,ten,tap):
self.ed = ed
self.typ = typ
self.day = day
self.ten = ten
self.tap = tap
def inra(self):
return "P{:03d} {} {} {} {}".format(self.ed,self.typ,self.day,self.ten,self.tap)
def ss(x,y):
if x[2]==y[2]:
if x[1]==y[1]:
if x[0]<y[0]:
return -1
elif x[0]>y[0]:
return 1
else:
return 0
elif x[1]<y[1]:
return -1
else:
return 1
elif x[2]<y[2]:
return -1
return 1
def cmp(a,b):
x = [int(i) for i in a.day.split('/')]
y = [int(i) for i in b.day.split('/')]
if ss(x,y)==0:
if a.ten==b.ten:
if a.tap<b.tap:
return 1
return -1
elif a.ten<b.ten:
return -1
return 1
return ss(x,y)
a = {}
b = []
n,m = [int(i) for i in input().split()]
for i in range(n):
a[i+1] = input()
ed = 1
for i in range(m):
idd = int(input()[2:])
day = input()
ten = input()
tap = int(input())
b.append(film(ed,a[idd],day,ten,tap))
ed+=1
b = sorted(b,key=functools.cmp_to_key(cmp))
for i in b:
print(i.inra())