← 返回 google 的题目列表Robot Status Message Deduplication
类型:online_judge
Problem: Robot Status Message Deduplication
A robot continuously sends status messages that need to be displayed to a human operator. Since many duplicate messages may appear within a short period of time, showing all of them would make the interface hard to read.
Implement a filtering system with the following rules:
If a message has already been displayed within the past 10 seconds, hide it.
If more than 10 seconds have passed since the message was last displayed, show it again.
Key detail: track the last time the message was displayed, not the last time it was received.
By default, this problem uses the strict rule: show the message only when currentTime - lastShownTime > 10. If the difference is exactly 10 seconds, hide it. If the interviewer wants >= 10, only the comparison needs to be changed.
Input Format
The first line contains an integer n, the number of received messages.
The next n lines each contain an integer timestamp followed by a string message, separated by a space.
The message may contain spaces, so everything after the first space belongs to the message.
Assume the input is sorted by non-decreasing timestamp.
Output Format
For each message, output one line:
SHOW if the message should be displayed.
HIDE if the message should be hidden.
Constraints
1 <= n <= 10^5
0 <= timestamp <= 10^9
1 <= len(message) <= 200
Messages are case-sensitive.
Example
Input:
3
10 solar panel activated
13 solar panel activated
21 solar panel activated
Output:
SHOW
HIDE
SHOW
Explanation:
t = 10: first occurrence, show it.
t = 13: only 3 seconds after the last display, hide it.
t = 21: 11 seconds after the last display, show it.
Example
Input
3
10 solar panel activated
13 solar panel activated
21 solar panel activated
Output
SHOW
HIDE
SHOW