#C8719. User Log Queries
User Log Queries
User Log Queries
You are given a series of operations to manage user login logs. There are two types of operations:
- ADD username timestamp: Add a log entry for a user identified by
username
at a giventimestamp
. - QUERY start_time end_time: Count the number of unique users who have at least one log entry with a timestamp in the range \(start\_time \leq timestamp \leq end\_time\) (inclusive).
The input starts with an integer T
representing the number of test cases. For each test case, the first line contains an integer Q
denoting the number of operations. The next Q
lines contain the operations. For each QUERY
operation, you should output a result on a new line.
Note: Use the following latex formula to represent the query condition:
\(start\_time \leq timestamp \leq end\_time\)
inputFormat
The input is read from standard input and has the following format:
T Q operation_1 operation_2 ... operation_Q ... (repeated for T test cases)
Here, T is the number of test cases, Q is the number of operations in a test case, and each operation
is either an ADD
or QUERY
command as described above.
outputFormat
For every QUERY
command, print an integer on a new line representing the number of unique users with at least one log entry in the interval defined by \(start\_time \leq timestamp \leq end\_time\).
1
5
ADD alice 100
ADD bob 200
ADD alice 300
QUERY 50 150
QUERY 100 300
1
2
</p>