VisaOA #12
Cache Query Handler
Estimated EasyJudge-ready
Topics (AI-labelled)Hashing
Cache records give timestamp, key, and value; for each (key,timestamp) query, return the corresponding value.
Input
n,q≤200000; then n lines of key timestamp value, followed by q lines of key timestamp. Times are HH:MM:SS, and value is an integer. This site adds the guarantee that (key,timestamp) is unique, removing the duplicate-key conflict the original problem left unspecified.
Output
Output each value in order, separated by spaces.
Example 1
Input:
2 2
a 10:00:00 7
b 10:00:00 9
b 10:00:00
a 10:00:00
Output:
9 7
Example 2
Input:
1 1
x 00:00:00 -1
x 00:00:00
Output:
-1
Example 3
Input:
2 2
a 12:30:00 4
a 12:31:00 5
a 12:31:00
a 12:30:00
Output:
5 4
Editorial
Loading solution…