#C4203. Log Processing and User Activity Aggregation

    ID: 47716 Type: Default 1000ms 256MiB

Log Processing and User Activity Aggregation

Log Processing and User Activity Aggregation

You are given a series of log entries. Each log entry contains a user_id, an action, and a timestamp. The task is to group the actions by user. For each user, the actions must be sorted in increasing order based on their timestamps. In case two log entries for the same user have the same timestamp, the order should follow the input order.

The output should list each user (sorted in lexicographical order) followed by a colon and the user’s actions joined by commas.

For example, if you have two users user1 and user2, your output might look like:

user1: login, click, logout
user2: click, logout

Note: You can assume that the input timestamps are non-negative integers. If there are no log entries, the output is an empty string.

Mathematically, if we denote the timestamp of a log entry as \(t_i\), then for each user the sequence of timestamps satisfies \[ t_{i} \leq t_{i+1} \] which ensures correct ordering of actions.

inputFormat

The input is read from standard input and consists of multiple lines. The first line contains a single integer \(n\) representing the number of log entries. Each of the next \(n\) lines contains three space-separated values: a user_id (a string without spaces), an action (a string without spaces), and a timestamp (a non-negative integer).

outputFormat

The output should be written to standard output. For each unique user (sorted in lexicographical order), print a single line in the format:

user_id: action1, action2, ...

If there are no log entries, output an empty string.

## sample
5
user1 login 1
user2 click 3
user1 logout 2
user2 logout 3
user1 click 1
user1: login, click, logout

user2: click, logout

</p>