fork download
  1. from typing import List
  2.  
  3.  
  4. class BoundCountMap:
  5.  
  6. def __init__(self, bound: List[List[str]]):
  7. self.data = {}
  8. self.bound = {}
  9. for group in bound:
  10. whole_group = set(group)
  11. for elem in group:
  12. self.data[elem] = 0
  13. self.bound[elem] = whole_group
  14.  
  15. def __getitem__(self, item):
  16. return self.data.get(item)
  17.  
  18. def __setitem__(self, key, value):
  19. for group_elem in self.bound[key]:
  20. self.data[group_elem] = value
Success #stdin #stdout 0.03s 9732KB
stdin
Standard input is empty
stdout
Standard output is empty