SOLVE

LATER

Hostel Visit

Problem

Editorial

Analytics

Dean of NIT Silchar is going to visit Hostels of NIT Silchar. 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 K^{th} nearest hostel from origin ( Dean's place ) .

**Input:**

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 1^{st} type, you came to know about the co-ordinates ( x , y ) of newly constructed hostel.

second type : 2

For query of 2^{nd} type, you have to output the Rocket distance of K^{th} 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 ( x_{2} , y_{2} ) and ( x_{1} , y_{1} ) is defined as (x_{2} - x_{1})^{2} + (y_{2} - y_{1})^{2}

**Output:**

For each query of type 2 output the Rocket distance of K^{th} nearest hostel from Origin.

**Constraints**

1 < = k < = Q < = 10^{5}

-10^{6} < = x , y < = 10^{6}

Explanation

The rocket distance of first k ( = 3 ) hostels in increasing order are 128 , 162 , 200

The Rocket distance of 3^{rd} nearest hostel till now is 200.

After another query of type 1 , the rocket distance of hostels in increasing order are 98 ,128 , 162 , 200.

The Rocket distance of 3^{rd} nearest hostel till now is 162.

After 2 query of type 1, the rocket distance of hostels in increasing order are 50 , 72 ,98 , 128 ,162 , 200.

The Rocket distance of 3^{rd} nearest hostel till now is 98.

Problem Setter : Satyam Swarnkar

Time Limit:
1.0 sec(s)
for each input file.

Memory Limit:
256 MB

Source Limit:
1024 KB

Marking Scheme:
Marks are awarded when all the testcases pass.

Allowed Languages:
C,
C++,
C++14,
Clojure,
C#,
D,
Erlang,
F#,
Go,
Groovy,
Haskell,
Java,
Java 8,
JavaScript(Rhino),
JavaScript(Node.js),
Julia,
Kotlin,
Lisp,
Lisp (SBCL),
Lua,
Objective-C,
OCaml,
Octave,
Pascal,
Perl,
PHP,
Python,
Python 3,
R(RScript),
Racket,
Ruby,
Rust,
Scala,
Swift,
Visual Basic

Initializing Code Editor...

{"7550ed9": "/pagelets/recommended-problems/algorithm/hostel-visit/", "50a6292": "/pagelets/problems-hint/algorithm/hostel-visit/", "6f7bc5e": "/pagelets/show-submission/algorithm/hostel-visit/", "52cb026": "/pagelets/suggested-problems/algorithm/hostel-visit/", "5ce855a": "/pagelets/problem-author-tester/algorithm/hostel-visit/"}

realtime.hackerearth.com

80

26dbbbbbdab8e621e0779cd510018869d7f36ef0

58a29e5cae2309f04b28

/realtime/pusher/auth/