Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. used_ip = {}
  2. curr_ip_list = []
  3. ind_last_ip = 0
  4. ans = set()
  5. n = int(input())
  6. m = int(input())
  7. k = int(input())
  8. if n >= m:
  9. for i in range(m):
  10. tmp_ip = input()
  11. curr_ip_list.append(tmp_ip)
  12. if used_ip.get(tmp_ip) is None:
  13. used_ip[tmp_ip] = 1
  14. else:
  15. used_ip[tmp_ip] += 1
  16. if used_ip[tmp_ip] >= k:
  17. ans.add(tmp_ip)
  18. for i in range(n - m):
  19. tmp_ip = input()
  20.  
  21. # Dell last ip.
  22. used_ip[curr_ip_list[ind_last_ip]] -= 1
  23. curr_ip_list[ind_last_ip] = tmp_ip
  24. ind_last_ip = (ind_last_ip + 1) % m
  25.  
  26. if used_ip.get(tmp_ip) is None:
  27. used_ip[tmp_ip] = 1
  28. else:
  29. used_ip[tmp_ip] += 1
  30. if used_ip[tmp_ip] >= k:
  31. ans.add(tmp_ip)
  32. print(*sorted(ans), sep='\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement