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++,
Clojure,
C#,
D,
Erlang,
F#,
Go,
Groovy,
Haskell,
Java,
Java 8,
JavaScript(Rhino),
JavaScript(Node.js),
Lisp,
Lisp (SBCL),
Lua,
Objective-C,
OCaml,
Octave,
Pascal,
Perl,
PHP,
Python,
Python 3,
R(RScript),
Racket,
Ruby,
Rust,
Scala,
Scala 2.11.8,
Swift,
Visual Basic

Initializing Code Editor...

{"37542e4": "/pagelets/problem-author-tester/algorithm/hostel-visit/", "37542ac": "/pagelets/show-submission/algorithm/hostel-visit/", "37542cd": "/pagelets/suggested-problems/algorithm/hostel-visit/", "375430f": "/pagelets/recommended-problems/algorithm/hostel-visit/", "37542fa": "/pagelets/problems-hint/algorithm/hostel-visit/"}

{}

realtime.hackerearth.com

80

26dbbbbbdab8e621e0779cd510018869d7f36ef0

58a29e5cae2309f04b28

/realtime/pusher/auth/