#C1246. Log Filtering Competition

    ID: 41889 Type: Default 1000ms 256MiB

Log Filtering Competition

Log Filtering Competition

You are given a set of log entries, where each log entry contains a timestamp, a log level, and a message. Your task is to output the messages from the logs which satisfy both of the following conditions:

  • The log's level matches a given log level.
  • The log's timestamp is between a specified start time and end time (inclusive).

The timestamps are given in the format \(\texttt{YYYY-MM-DD HH:MM:SS}\). Make sure your solution reads input from stdin and outputs the result to stdout exactly as specified.

inputFormat

The input is given in the following format:

N
log_entry_1
log_entry_2
... 
log_entry_N
filter_level
start_time
end_time

Here:

  • N is an integer representing the number of log entries.
  • Each log_entry is a single line in the format timestamp|level|message. The fields are separated by a vertical bar ("|").
  • filter_level is a string (for example, INFO, WARNING, or ERROR) specifying the log level to filter.
  • start_time and end_time are timestamps in the format \(\texttt{YYYY-MM-DD HH:MM:SS}\) defining the inclusive range for filtering.

outputFormat

Output the messages that match the criteria, each on a separate line. If no log entries match the criteria, output nothing.

## sample
4
2023-01-01 12:00:00|INFO|Application started
2023-01-01 13:00:00|WARNING|High memory usage
2023-01-01 14:00:00|ERROR|Application crashed
2023-01-02 09:00:00|INFO|Application restarted
WARNING
2023-01-01 11:00:00
2023-01-01 14:30:00
High memory usage