VisaOA #3
Chat Mention Counter
估计中等可在线判题
Process messages and offline events in event order. A message sender becomes an existing and active user when they post. A mention token can be a user ID, ALL, or HERE; ALL covers all existing users, and HERE covers currently active users. Each user is counted at most once per message; self-mentions count. Output the IDs with positive counts and their counts, sorted lexicographically by ID.
输入格式
q (1≤q≤1000). Then q lines follow: MESSAGE sender timestamp m token1..tokenm, or OFFLINE user. m≥0, and IDs have the form id followed by a positive integer; timestamps are non-negative integers, and events are processed in input order. The total number of direct mention tokens is ≤200000; q≤1000 is a site-added limit on the expanded size.
Site-added ranges: user IDs are id followed by a decimal integer in 1..10^9, and timestamp is 0..10^9;
输出格式
Output id=count entries sorted lexicographically by ID, separated by spaces; if there are no counts, output an empty line.
样例 1
输入:
1
MESSAGE id1 1 3 id1 id2 id2
输出:
id1=1 id2=1
样例 2
输入:
1
MESSAGE id1 1 1 ALL
输出:
id1=1
样例 3
输入:
3
MESSAGE id1 1 1 HERE
OFFLINE id1
MESSAGE id2 2 1 ALL
输出:
id1=2 id2=1