fork download
  1. from datetime import datetime
  2.  
  3.  
  4. class TheLoai:
  5. def __init__(self, maTL, tenTL) -> None:
  6. self.maTL = f'TL{maTL:03d}'
  7. self.tenTL = tenTL
  8.  
  9.  
  10. class BoPhim:
  11. def __init__(self, maPhim, maTL, ngayChieu, tenPhim, soTap, theLoai) -> None:
  12. self.maPhim = f'P{maPhim:03d}'
  13. self.maTL = maTL
  14. self.ngayChieu = datetime.strptime(ngayChieu, '%d/%m/%Y')
  15. self.tenPhim = tenPhim
  16. self.soTap = soTap
  17. self.theLoai = theLoai
  18.  
  19. def __str__(self) -> str:
  20. return f'{self.maPhim} {self.theLoai.tenTL} ' + self.ngayChieu.strftime('%d/%m/%Y') + f' {self.tenPhim} {self.soTap}'
  21.  
  22.  
  23. if __name__ == '__main__':
  24. n, m = map(int, input().split())
  25. a = []
  26. for i in range(n):
  27. a.append(TheLoai(i + 1, input().strip()))
  28. b = []
  29. for i in range(m):
  30. b.append(BoPhim(i + 1, input().strip(), input().strip(), input().strip(), int(input()), None))
  31. for it in b:
  32. for x in a:
  33. if it.maTL == x.maTL:
  34. it.theLoai = x
  35. break
  36. b.sort(key = lambda x : (x.ngayChieu, x.tenPhim, -x.soTap))
  37. for x in b:
  38. print(x)
Success #stdin #stdout 0.13s 16048KB
stdin
2 3
Hai huoc
Tinh cam
TL001
25/11/2021
Phim so 1
10
TL001
04/12/2021
Phim so 2
15
TL002
25/11/2021
Phim so 3
5
stdout
P001 Hai huoc 25/11/2021 Phim so 1 10
P003 Tinh cam 25/11/2021 Phim so 3 5
P002 Hai huoc 04/12/2021 Phim so 2 15