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
Hostel Visit(Wrong Answer)
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:
-
The first line contains two inputs:
1.1. q: no. of queries
1.2. k: which is same for the entire input -
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.