IBMOA #42
Get Query Answers
Estimated EasyJudge-ready
Topics (AI-labelled)Hashing
A cache entry contains timestamp, key and an integer value; each query gives key and timestamp and returns the value of that exact entry, not the version with the nearest time. Keys do not repeat at the same time, and every query is guaranteed to hit.
Input
The first line contains n q, followed by n lines of timestamp key value, then q lines of key timestamp. 1≤n,q≤100000, 1≤value≤10^8; times are 8-character hh:mm:ss (hours 00..23, minutes and seconds 00..59); keys consist of lowercase letters and digits. On this site keys are 1..64 characters.
Output
Output q lines of integers in query order.
Example 1
Input:
2 2
01:34:05 abc 352
20:34:20 a1 490
a1 20:34:20
abc 01:34:05
Output:
490
352
Example 2
Input:
2 1
00:00:00 x 1
00:00:01 x 2
x 00:00:00
Output:
1
Example 3
Input:
2 2
12:00:00 a 8
12:00:00 b 9
b 12:00:00
a 12:00:00
Output:
9
8
Example notes
The examples give 490 and 352; 1; and 9 and 8 respectively.
Editorial
Loading solution…