#C11234. Event Occurrence Counter
Event Occurrence Counter
Event Occurrence Counter
You are given two sequences: one representing events that have already occurred, and another representing queries. For each query, you must report the number of times the queried event has occurred so far, then increment the count for that event. More formally, let (A) be an array of length (n) and (B) be an array of length (q). For each query (B_i), output the current count (c) of (B_i) in (A) and then update (c) to (c+1).
inputFormat
The input is read from standard input and consists of three lines:
- The first line contains two space-separated integers (n) and (q), representing the number of events and the number of queries respectively.
- The second line contains (n) space-separated integers, the event identifiers (if (n = 0), this line will be empty).
- The third line contains (q) space-separated integers, the queries.
outputFormat
Output a single line containing (q) space-separated integers. Each integer is the count of the queried event at the moment of the query.## sample
6 4
1 2 1 3 1 2
1 2 3 1
3 2 1 4