ACMCEG2B - FIGUREFUL
Don and his friends had some sort of code word to describe the girls who pass towards their class.
Anitha passed - killer told.. “Dude, 5 2 is going”
Chitra passed - Jumbo told.. “Dude, 6 4 is awesome”
Divya passed - Baabi told.. “Machi 1 6 is my dream girl”
Girls couldn’t understand those code words. To crack the code word, girls decide to record all the code words and the girls' name whenever they call.
The silencer in the class watched all these and got angry. He mugged up all the code words, went to teacher and complained about the naughty boys and naughty girls.
Teacher : Who is the girl with code word 1 6?
Teacher: Who is the girl with code word 5 2?
Teacher: What is the code word for me??
Now you have to pretend that you are the Silencer to solve this problem. Record the code words and answer the questions the teacher asks you.(She may ask the same question any number of times)
Note: There can be any number of code words for a same girl. If there exist more than one girl for a same code word, then that code word belongs to the latest girl.
The first line contains an integer n, the number of figures. Then in each of the next n lines there will be 2 integers and a figure name.
After that there will be an integer t, the number of test cases. For each test case, there will be two integers representing the code word. Print the figure’s name corresponding to the code word.
For each test case output the figure name.
The figure’s name will not exceed 20 characters
5 2 Anitha
6 4 Yamuna
6 4 Chitra
1 6 Divya
-2 0 Teacher
7 4 Anitha
Hint: Use map
For all those trying to submit solution in Java, I know its a challenging one to overcome the Time Limit problem.
hashing makes it easy
For java i am getting TLE can any one share test cases ?Last edit: 2018-05-17 12:46:37
It not getting submitted
AC in one go :P