Skip to content
Discussion options

You must be logged in to vote

We need to count the number of valid pairs of points where Alice can be placed at the upper left corner and Bob at the lower right corner of a rectangular fence such that no other point lies inside or on the boundary of the fence. The solution involves sorting the points and then efficiently checking each possible pair to ensure the condition is met.

Approach

  1. Sorting: First, sort the points primarily by their x-coordinates in ascending order. For points with the same x-coordinate, sort them by their y-coordinates in descending order. This ensures that when we consider a point i as Alice and a point j as Bob, where i < j, the x-coordinate of i is less than or equal to that of j, and if t…

Replies: 1 comment 2 replies

Comment options

mah-shamim
Sep 3, 2025
Maintainer Author

You must be logged in to vote
2 replies
@basharul-siddike
Comment options

@mah-shamim
Comment options

mah-shamim Sep 3, 2025
Maintainer Author

Answer selected by basharul-siddike
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested hard Difficulty
2 participants