#K14866. Engagement Score Calculation
Engagement Score Calculation
Engagement Score Calculation
You are given a series of interaction logs for several posts. Each log contains a timestamp, a user ID, a post ID, and an interaction type. The interaction types and their corresponding weights are:
\( \text{like} = 1, \quad \text{comment} = 2, \quad \text{share} = 3 \)
Your task is to calculate the engagement score for each post within a specific time interval \( [start\_time,\ end\_time] \) (inclusive). The engagement score for a post is the sum of weights of all interactions that occurred during the given time period. Print the results sorted by the post ID in ascending order.
The timestamps are given in the \( YYYY\text{-}MM\text{-}DD\ HH:MM:SS \) format.
inputFormat
The input is provided via standard input (stdin) and is formatted as follows:
- The first line contains two integers \( n \) and \( m \), where \( n \) is the number of interaction logs and \( m \) is the number of posts.
- The second line contains four strings representing the start time and end time: \( start\_date\ start\_time\ end\_date\ end\_time \). Combine the first two tokens to form the start time and the last two tokens for the end time.
- The following \( n \) lines each contain a log entry with five fields separated by spaces:
- A date in the format YYYY-MM-DD
- A time in the format HH:MM:SS
- A user ID (string)
- A post ID (integer)
- An interaction type (either "like", "comment", or "share")
outputFormat
Output the engagement score for each post (from post 1 to post m) on a separate line. Each line should contain the post ID and its calculated engagement score separated by a space.
## sample5 3
2023-01-01 00:00:00 2023-01-02 00:00:00
2023-01-01 10:00:00 1 1 like
2023-01-01 11:00:00 2 1 share
2023-01-01 12:00:00 3 2 comment
2023-01-01 13:00:00 4 2 like
2023-01-01 14:00:00 1 1 comment
1 6
2 3
3 0
</p>