Under construction

Still being built. Things may change

Cyber Opening Ceremony

Interview

Time limit1sMemory limit1024 MB

Summary
Given start, end, and stream-end times plus chat logs, count members who chatted at or before the start and again between the end and stream-end.
Level

Medium4 of 10

Topics
Hash map, Implementation, Sorting, String
Solved
No attempts yet

Problem

Boyoung runs the algorithm club HI-ARC.

Boyoung and the club officers worked hard to prepare a welcome for the freshmen entering in 2020, but as the epidemic worsened, the government declared "social distancing," and the school notified all clubs on campus to refrain from offline meetings. Even in this difficult situation with the recommendation to avoid offline gatherings, Boyoung used her wits and decided to replace the opening ceremony with a Mytube stream.

However, holding the opening ceremony as a Mytube stream came with the following problems.

  1. There is no way to know who came to the opening ceremony.
  2. There is no way to know who stayed until the end of the opening ceremony.
  3. There is no way to know who merely left the opening ceremony stream running.

To solve these problems, she decided to manage the attendance list as follows.

  1. Before the opening ceremony begins, check whether each member's entry is confirmed. A member's entry is checked by looking at the nicknames of members who have chatted before the time the opening ceremony started. A member who leaves a chat message at the very moment the opening ceremony starts is also considered to have had their entry confirmed on time.
  2. After the opening ceremony ends and until the stream ends, check whether each member's exit is confirmed. A member's exit is checked by looking at the nicknames of members who have chatted between the end of the opening ceremony and the end of the stream. A member who leaves a chat message at the very moment the opening ceremony ends, or at the very moment the opening ceremony stream ends, is also considered to have had their exit confirmed on time.

From 00:00 onward is the waiting time before the opening ceremony starts, and chat records left after the time the opening ceremony stream ended are considered chat records of a different streamed video.

How many members have both their entry and exit confirmed?

Input

The first line gives the time the opening ceremony started S, the time the opening ceremony ended E, and the time the opening ceremony stream ended Q. (00:00 ≤ S < E < Q ≤ 23:59)
Each time is given in the format HH:MM.

From the second line onward, the chat records of the streamed video broadcast by HI-ARC are given in chronological order, each in the form (time) (member nickname). A member's nickname is a string consisting only of uppercase and lowercase letters, digits, and the special symbols (., _, -), with a maximum length of 20 characters.

All chat records occurred on the day the opening ceremony took place. That is, only times from 00:00 to 23:59 are given. There are no more than 100,000 chat records.

Output

Output the number of members whose attendance is confirmed.

Hint

The description of the problem differs from the facts.

Examples2

  1. Example 1

    Input
    22:00 23:00 23:30
    21:30 malkoring
    21:33 tolelom
    21:34 minjae705
    21:35 hhan14
    21:36 dicohy27
    21:40 906bc
    23:00 906bc
    23:01 tolelom
    23:10 minjae705
    23:11 hhan14
    23:20 dicohy27
    
    Expected output
    5
    
  2. Example 2

    Input
    06:00 12:00 18:00
    06:00 shinyo17
    06:00 kimchist
    06:00 swoon
    06:00 kheee512
    06:00 Green55
    09:00 kimchist
    11:59 shinyo17
    12:00 kimchist
    17:59 swoon
    17:59 swoon
    18:00 kheee512
    18:01 swoon
    18:01 Green55
    18:01 kheee512
    18:01 swoon
    18:21 jinius36
    18:40 jeongyun1206
    
    Expected output
    3