#C9874. Identify Unique IP Addresses by Access Count

    ID: 54015 Type: Default 1000ms 256MiB

Identify Unique IP Addresses by Access Count

Identify Unique IP Addresses by Access Count

You are given a log of access attempts. Each log entry contains an IP address and a timestamp in the format \(YYYY-MM-DD\ HH:MM:SS\). Given a time interval and an integer \(n\), your task is to identify all unique IP addresses that have made exactly \(n\) access attempts within the inclusive time interval. The resulting IP addresses should be output in lexicographical order, one per line.

Note: The timestamps are provided in a fixed format, so you may perform lexicographical comparisons directly if desired.

inputFormat

The input is provided via standard input (stdin) in the following format:

  1. The first line contains two timestamps separated by a space representing the start and end of the interval, respectively. Each timestamp is in the format \(YYYY-MM-DD\ HH:MM:SS\).
  2. The second line contains an integer \(n\), representing the exact number of access attempts.
  3. The third line contains an integer \(k\), representing the number of log entries that follow.
  4. Each of the next \(k\) lines contains a log entry consisting of an IP address and a timestamp (in the same format) separated by a space. Note that the timestamp itself has a space between the date and time.

outputFormat

Output the IP addresses (each on a new line) that made exactly \(n\) access attempts within the given interval, sorted in lexicographical order. If no IP address satisfies the condition, output nothing.

## sample
2023-01-01 12:00:00 2023-01-01 12:30:00
3
7
192.168.1.1 2023-01-01 12:00:00
192.168.1.2 2023-01-01 12:05:00
192.168.1.1 2023-01-01 12:10:00
192.168.1.3 2023-01-01 12:15:00
192.168.1.2 2023-01-01 12:20:00
192.168.1.1 2023-01-01 12:25:00
192.168.1.3 2023-01-01 12:30:00
192.168.1.1