Count how many times each user is mentioned across a sequence of timestamped events, with special handling for active and all-users mentions.
You are given a set of users and a chronological list of events. Some events contain mentions that can refer to specific users by id, while others can target all users or only currently active users.
Your task is to process the events in time order and compute, for each user, how many times they are mentioned according to the rules of the problem. The exact mention semantics depend on the event type, but the core challenge is to aggregate counts correctly while handling ordering and time-based state changes.
Return the mention count for every user in user-id order.
Example 1
Input
users = 3 entries = [ [1, "MESSAGE", [0, 2]], [2, "ALL", []], [3, "MESSAGE", [1]], [4, "ACTIVE", [0, 1, 2]] ]
Output
[2, 2, 2]
Explanation
User 0 is mentioned in the first message and by the ACTIVE event. User 1 is mentioned in the third message and by the ACTIVE event. User 2 is mentioned in the first message and by the ALL event.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.