Islands-Problem Description:-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 powerFor 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 ofthe 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 distanceis 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.- Constraints1 <= N<= 100000-10^9 <= x1, y11,x21,721 <= 10^9.- Input FormatFirst 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) (1N)Islands are numbered 1,2,NThe final line contains 2 integer separated by space denoting the coordinates of the warship- OutputN integers separated by space each integer denoting the index of island sorted by distance from warship in non decreasing orderif 2 islands are at the same distance from warship, rank them according to their index- Test Caseten a $39a400 m
Answers
Answer:
dont know!!!!
Explanation:
no one wants to answer this for just 5 point
.
.
.first u have to increase the points
.
.
.
.
.
please follow me
Answer:
import java.util.*;
Class pro
{
public static void main(String args[])
{
int n,arr1[][],x,y,arr2[][],sh1,sh2,sh3,sh4,d;
arr1=new int[100][4];
arr2=new int[100][2];
int t,i,j;
System.out.println(“Enter input”)
n=sc.nextInt();
for(i=0;i<n;i++)
{
arr[i][0]= sc.nextInt();
arr1[i][1]= sc.nextInt();
arr1[i][2]= sc.nextInt();
arr1[i][3]= sc.nextInt();
arr2[i][0]=i+1;
}
System.out.println(“Enter input for x”)
x=sc.nextInt();
System.out.println(“Enter input for y”)
y=sc.nextInt();
for(i=0;i<n;i++)
{
sh1=abs(x-arr1[i][0])+abs(y-arr1[i][1]);
sh2=abs(x-arr1[i][2])+abs(y-arr1[i][3]);
sh3=abs(x-arr1[i][0])+abs(y-arr1[i][3]);
sh4=abs(x-arr1[i][2])+abs(y-arr1[i][1]);
d=sh1;
if(d>sh2)
d=sh2;
if(d>sh3)
d=sh3;
if(d>sh4)
d=sh4;
arr2[i][1]=d;
}
for(i=0;i<n;i++)
for(j=0;j<n-1;i++)
{
if(arr2[j][1]>arr2[j+1][1])
{
t=arr2[j][1];
arr2[j][1]=arr2[j+1][1];
arr2[j+1][1]=t;
t=arr2[j][0];
arr2[j][0]=arr2[j+1][0];
arr2[j+1][0]=t;
}
}
for(i=0;i<n;i++)
System.out.println(“\t”+arr2[i][0]);
}