SHARE
TWEET

Untitled

a guest Jul 17th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top