Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- used_ip = {}
- curr_ip_list = []
- ind_last_ip = 0
- ans = set()
- n = int(input())
- m = int(input())
- k = int(input())
- if n >= m:
- for i in range(m):
- tmp_ip = input()
- curr_ip_list.append(tmp_ip)
- if used_ip.get(tmp_ip) is None:
- used_ip[tmp_ip] = 1
- else:
- used_ip[tmp_ip] += 1
- if used_ip[tmp_ip] >= k:
- ans.add(tmp_ip)
- for i in range(n - m):
- tmp_ip = input()
- # Dell last ip.
- used_ip[curr_ip_list[ind_last_ip]] -= 1
- curr_ip_list[ind_last_ip] = tmp_ip
- ind_last_ip = (ind_last_ip + 1) % m
- if used_ip.get(tmp_ip) is None:
- used_ip[tmp_ip] = 1
- else:
- used_ip[tmp_ip] += 1
- if used_ip[tmp_ip] >= k:
- ans.add(tmp_ip)
- print(*sorted(ans), sep='\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement