Computer Science, asked by ramkrishna16951, 10 months ago

In the Indian Ocean, there are several small islands. A war ship is stationed in the ocean and wants to find how many of these islands are within its striking power. For simplicity, the islands are all assumed to have square shapes and again, the curvature of the earth can be ignored. The coordinates of two opposite corners of the islands are given and the position of the ship is also given. You need to find the islands in the increasing sequence of their distances from the ship. The distance is the shortest distance – the distance of the nearest point on the island boundary from the ship. Use Manhattan Distance, i.e. distance between 2 points (x1,y1) and (x2,y2) is |x1-x2| + |y1-y2|.

Constraints

1 <= N <= 100000.

-10^9 <= x1i, y1i, x2i,y2i <= 10^9.

Input Format

First line contains single integer N denoting the number of islands.

Next N lines contain 4 integers separated by space denoting the coordinates of the opposite corners of the islands (x1i, y1i) & (x2i,y2i). (1 <= i <= N)

Islands are numbered 1, 2, …, N.

The final line contains 2 integer separated by space denoting the coordinates of the warship.

Output

N integers separated by space each integer denoting the index of island sorted by distance from warship in non-decreasing order.

If 2 islands are at the same distance from warship, rank them according to their index

Answers

Answered by sakshigupta123446
7

Answer:

In the Indian Ocean, there are several small islands. A war ship is stationed in the ocean and wants to find how many of these islands are within its striking power

For simplicity, the islands are all assumed to have square shapes and again, the curvature of the earth can be ignored. The coordinates of two opposite comers of

the islands are given and the position of the ship is also given. You need to find the islands in the increasing sequence of their distances from the ship. The distance

is the shortest distance - the distance of the nearest point on the island boundary from the ship. Use Manhattan Distance, i.e distance between 2 points (x1.yt)

and (x2,72) is 1x1-x2) + ly1-y21.

- Constraints

1 <= N<= 100000

-10^9 <= x1, y11,x21,721 <= 10^9.

- Input Format

First line contains single integer N denoting the number of islands.

Next N lines contain 4 integers separated by space denoting the coordinates of the opposite corners of the islands (xli yli) & (21.42D) (

1

N

)

Islands are numbered 1,2,

N

The final line contains 2 integer separated by space denoting the coordinates of the warship

- Output

N integers separated by space each integer denoting the index of island sorted by distance from warship in non decreasing order

if 2 islands are at the same distance from warship, rank them according to their index

- Test Case

ten a $

39

a

400 m

mark brainliest

Similar questions