#C4992. Detecting Suspicious IP Addresses in Log Files

    ID: 48591 Type: Default 1000ms 256MiB

Detecting Suspicious IP Addresses in Log Files

Detecting Suspicious IP Addresses in Log Files

You are given a series of log entries from a system, where each log contains a timestamp and an IP address representing a failed login attempt. Your task is to determine which IP addresses qualify as suspicious. An IP address is considered suspicious if it appears more than \(K\) times within any sliding window of \(T\) seconds.

More formally, given a list of log entries, each with a timestamp in the format "YYYY-MM-DD HH:MM:SS" and an IP address, and two integers \(K\) and \(T\), identify all IP addresses that have more than \(K\) failed attempts within any window of \(T\) seconds. If there are any suspicious IP addresses, output them in order of the time of the \(K\)-th failed attempt (i.e. the time when they exceeded the threshold). If no IP address meets the criteria, output No suspicious IPs.

Note: The input is read from standard input (stdin) and the output is printed to standard output (stdout).

inputFormat

The first line contains three integers (N), (K), and (T) separated by spaces, where (N) is the number of log entries. Each of the next (N) lines contains a timestamp and an IP address separated by a space. The timestamp is in the format "YYYY-MM-DD HH:MM:SS".

outputFormat

Print each suspicious IP address on a separate line in the order determined by the time of the (K)-th failed attempt. If there are no suspicious IP addresses, print exactly "No suspicious IPs".## sample

7 3 60
2023-01-01 00:00:01 192.168.1.1
2023-01-01 00:00:05 192.168.1.2
2023-01-01 00:00:10 192.168.1.1
2023-01-01 00:00:15 192.168.1.3
2023-01-01 00:00:21 192.168.1.1
2023-01-01 00:00:30 192.168.1.2
2023-01-01 00:00:35 192.168.1.1
192.168.1.1