IBMOA #11
Cache Query Handler
Estimated EasyJudge-ready
Topics (AI-labelled)Hashing
Each cache entry contains a time, a key and an integer value in string form; each query gives a key and an exact time. Every queried entry is guaranteed to exist, and no key repeats at the same time. Return the corresponding original value string; do not look up the nearest time.
Input
The first line contains n q, followed by n lines of time key value, and finally q lines of key time. 1≤n,q≤100000; times are valid hh:mm:ss; values represent 1..10^8. The source does not limit the text length of keys or values; on this site keys are 1..64 lowercase letters or digits, values are 1..64 decimal digits (leading 0 allowed), and the total input is ≤16MiB.
Output
Output the original value strings in query order.
Example 1
Input:
3 2
12:30:22 a 125
09:07:47 b 341
01:23:09 a 764
a 01:23:09
b 09:07:47
Output:
764 341
Example 2
Input:
1 1
00:00:00 a 0007
a 00:00:00
Output:
0007
Example 3
Input:
2 1
00:00:00 a 1
00:00:01 a 2
a 00:00:00
Output:
1
Example notes
The examples give 764 341; 0007; and 1 respectively; leading zeros in value strings are preserved.
Editorial
Loading solution…