#S0006. 用户访问日志
用户访问日志
1. Description
On apps like Twitter and TikTok, we often need to conduct user activity analysis to summarize user behavior on the platform and identify the users we should pay the most attention to.
Implement a user visit frequency analyzer. Input multiple access records (format: userID timestamp, e.g., u123 09:30). Count each user's daily visits and output the top 3 users by frequency. Tie-breaking rules:
- Sort by most recent visit time (latest first)
- If timestamps are identical, sort by userID alphabetically
2. Input & Output
Input:
- Multiple lines of records (userID and timestamp separated by space)
- End input with EOF (Press
Ctrl+DorCtrl+Zafter typing)
Output:
- Top 3 users in format
userID count latest_timestamp - Each user in a separate line
Example
# Input:
u3 14:20
u1 09:15
u3 08:45
u2 12:30
u3 16:10
# Output:
u3 3 16:10
u2 1 12:30
u1 1 09:15
# Input:
bot007 00:01
bot007 00:03
bot007 00:05
userA 14:00
# Output:
bot007 3 00:05
userA 1 14:00