Bowling Ball Finder
Time limit1sMemory limit1024 MB
Each type 1 request puts a ball of a given weight into a locker, and each type 2 request asks which locker holds the ball of a given weight.
- Level
Easy3 of 10
- Topics
- Hash map, Implementation
- Solved
- No attempts yet
Problem
Donghyun is an excellent programmer who loves bowling. Today he wants to bowl again, and while looking over his collection of bowling balls, he cannot decide which one to take. He wants to control even tiny differences in weight depending on his condition each day, so he owns a very large number of balls with many different weights. The locker that stores the balls lists the weights of the balls inside it, and one locker can hold several balls. Donghyun wants to focus only on bowling, so he asks you to manage the balls.
Manage the bowling balls as Donghyun requests.
The requests are as follows.
1 x w: Put a ball of weight into locker .2 w: Print the number of the locker that holds a ball of weight .
All of Donghyun's balls have different weights, so the answer to a type 2 request is always exactly one locker.
When a type 2 request comes in, a ball of weight always exists somewhere.
Input
The first line contains the number of requests (). The next lines contain the requests.
1 x w: Put a ball of weight into locker . (, is an integer), (, is an integer)2 w: Print the number of the locker that holds a ball of weight . (, is an integer)
When a type 2 request comes in, a ball of weight always exists somewhere.
There is at least one type 2 request.
Output
For each type 2 request, print the number of the locker.