Hostel Visit(Wrong Answer)

My program runs fine on the sample input but fails on the test cases. Please tell what am I doing wrong?
Here’s a link to my code

Hello @isa67719,

You are not dealing with the queries properly.

Reason:
You have misunderstood the input format.
What is the use of n in your code?
you have fixed the k to 2.

Considerations:

  1. The first line contains two inputs:
    1.1. q: no. of queries
    1.2. k: which is same for the entire input

  2. The next q lines contain queries of two type:
    2.1. in x y:
    … in=1
    … x: first coordinate
    … y: second coordinate
    (build the max heap)
    2.2. in
    … in=2
    (to print the distance of kth nearest hostel)

Hope, this would help.
Give a like, if you are satisfied.

1 Like

Thanks brother !! I understood my mistake and solved it.

Anytime @isa67719,

Please, mark this doubt as resolved.