Can you please help me understand the problem statement
Hostel Visit Problem
in each query, you are either given distance to add or you are asked kth distance.
try to understand with given test case and read carefully. Its easy to understand and no one has ever faced this problem.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
Hi Mridul, thanks for your response.
I’m sorry but m still not clear with the question.
Like, if i check the Input sample,
9 3 // 9 queries and K=3 …so the distance of 3rd nearest hostel to be determined?is it like that?
1 10 10 // here if X=1,y=10 then whats the 3rd number?
1 9 9
1 -8 -8
2
1 7 7
2
1 6 6
1 5 5
2
Hostel Visit
Dean of MAIT is going to visit Hostels of MAIT. As you know that he is a very busy person so he decided to visit only first “K” nearest Hostels. Hostels are situated in 2D plane. You are given the coordinates of hostels and you have to answer the Rocket distance of Kth nearest hostel from origin ( Dean’s place ) .
Input Format:
First line of input contains Q Total no. of queries and K There are two types of queries:
first type : 1 x y For query of 1st type, you came to know about the co-ordinates ( x , y ) of newly constructed hostel. second type : 2 For query of 2nd type, you have to output the Rocket distance of Kth nearest hostel till now.
The Dean will always stay at his place ( origin ). It is gauranted that there will be atleast k queries of type 1 before first query of type 2.
Rocket distance between two points ( x2 , y2 ) and ( x1 , y1 ) is defined as (x2 - x1)2 + (y2 - y1)2
Constraints:
1 < = k < = Q < = 10^5 -10^6 < = x , y < = 10^6
output format
For each query of type 2 output the Rocket distance of Kth nearest hostel from Origin.
sample input
9 3
1 10 10
1 9 9
1 -8 -8
2
1 7 7
2
1 6 6
1 5 5
2
sample output
200
162
98
1 10 10 means query type 1 ie add a point (10,10) = 100
1 9 9 means add (9,9) = 81
2 means answer out kth distance.
Hi Mridul, i got it now.
Thanks for explaining it.
Sorry, for troubling you as i couldn’t interpret it previously .
Thanks,
That’s alright 
You may mark the thread as resolved now. Please give a rating 