z-mushrooms
Mr Little Z got really bored one day, and decided to watch a field where mushrooms are growing. He was so bored that he decided to give a name to each of mushroom that pops out of the ground.
The field can be imagined as a 2D plane, and each mushroom can pop out at some coordinate (x,y). As soon as the mushroom pops out of the ground Little Z gives it a name.
However, sometimes there are no mushrooms growing out for hours, and in that case little Z is playing the following game. He asks himself what is the name of the mushroom that is the closest to some coordinate (x,y) - by closest we mean the closest in Eculedian distance
You have to help Mr. Little Z by writhing a program that will keep track of all the mushrooms that are growing out of the ground, and answer questions about which mushroom is currently closest to some fixed point (x,y)
- G [x] [y] [name], which is a character "G" followed by two real numbers (three decimal point precision) and a string (made of the letters of the English alphabet and digits 0-9, with max 20 characters). This line represents that there is a mushroom growing at (x,y), and little z named it with [name].
- Q [x] [y]. which is character "Q" followed by two real numbers (three decimal point precision). This line of input represents a question that you have to answer: what is the name of the mushroom closest to (x,y).
All the values of [x] and [y] will be in the range [0 10000]
4
G 1.000 1.000 boba
G 2.000 2.000 aleks
Q 1.500 1.500
Q 1.200 1.200Output:
aleks
boba4
G 1.000 1.000 boba
Q 100.000 100.000
G 2.000 1.000 dule
Q 100.000 100.000Output:
boba
duleSubmit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.