#K51667. Sensor Alert Report

    ID: 29139 Type: Default 1000ms 256MiB

Sensor Alert Report

Sensor Alert Report

You are given a series of sensor messages. Each message is formatted as SensorID:HH:MM:Status, where:

  • SensorID is an integer representing the sensor's unique identifier.
  • HH:MM represents the time in 24-hour format.
  • Status is a string which can be either OK or ALERT.

Your task is to process the messages to generate an alert report. Specifically, you must:

  1. Count the total number of messages with a status of ALERT.
  2. List all distinct sensor IDs that reported an alert in ascending order.
  3. Determine the time of the last alert (i.e. the time from the last message with status ALERT in the given order).
  4. </p>

    If there are no alerts, the list of sensor IDs and the last alert time should be reported as None.

    The time should be output in the format HH:MM.

    For reference, if we let $n$ be the number of messages and $m_i$ be each message, then a message is defined as:

    \[ m_i = \texttt{SensorID:HH:MM:Status} \]

    inputFormat

    The input is given via stdin in the following format:

    1. The first line contains an integer $n$, the number of sensor messages.
    2. The next $n$ lines each contain a sensor message in the format SensorID:HH:MM:Status.

    outputFormat

    The output should be printed to stdout in three lines:

    1. The first line contains the total number of alerts (an integer).
    2. The second line contains the distinct sensor IDs (space-separated) that reported alerts in ascending order. If there are no alerts, print None.
    3. The third line contains the time of the last alert in the format HH:MM. If there are no alerts, print None.
    ## sample
    6
    1:08:30:OK
    2:09:15:ALERT
    3:10:00:ALERT
    4:10:30:OK
    2:10:45:ALERT
    1:11:00:OK
    
    3
    

    2 3 10:45

    </p>