Advertisement
aanodin

Untitled

Apr 28th, 2020
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. N = int(input())
  2. M = int(input())
  3.  
  4. sizes = []
  5. for i in range(N):
  6.     sizes.append(input())
  7.  
  8. names = []
  9. for i in range(M):
  10.     name = input().split()
  11.     names.append((name[0], int(name[1])))
  12.  
  13. #names = sorted(names, key=lambda x: x[1])
  14.  
  15. #print(sizes, names)
  16.  
  17. applied = {idx: 0 for idx, _ in enumerate(sizes)}
  18.  
  19.  
  20. for name in names:
  21.     name_len = name[1]
  22.     name_first = name[0]
  23.     size = sizes[name_len - 1]
  24.  
  25.     if size == 'C' and (name_first == 'A' or name_first == 'B'):
  26.         continue
  27.  
  28.     if size == 'B' and (name_first == 'A'):
  29.         continue
  30.  
  31.     # name applied
  32.     applied[name_len - 1] += 1
  33.     print(name, size)
  34.  
  35. counter = 0
  36. for idx, cnt in applied.items():
  37.     if cnt == 1:
  38.         counter += 1
  39.  
  40. print(counter)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement