Cod sursa(job #1262091)

Utilizator CristinaElenaFMI Ciort Elena Cristina CristinaElena Data 12 noiembrie 2014 23:12:47
Problema Cele mai apropiate puncte din plan Scor 0
Compilator java Status done
Runda Arhiva educationala Marime 2.69 kb
public class GlobalMembersCelemaia
{
	public static data[] px = tangible.Arrays.initializeWithDefaultdataInstances(100010);
	public static data[] py = tangible.Arrays.initializeWithDefaultdataInstances(100010);

	public static int n;

	public static boolean cmp1(data a, data b)
	{
		return a.x < b.x;
	}

	public static boolean cmp2(data a, data b)
	{
		return a.y < b.y;
	}

	public static long dist(data a, data b)
	{
		return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
	}

	public static long minim(long a, long b)
	{
		return (a <= b != 0?a:b);
	}

	public static long dei(int st, int dr)
	{
		long mid;
		long sol;
		int k;
		if (st == dr)
		{
			return 1L << 61;
		}
		if (st + 1 == dr)
		{
//C++ TO JAVA CONVERTER WARNING: The following line was determined to be a copy constructor call - this should be verified and a copy constructor should be created if it does not yet exist:
//ORIGINAL LINE: return dist(px[st],px[dr]);
			return GlobalMembersCelemaia.dist(new data(px[st]), new data(px[dr]));
		}
		mid = (st + dr) / 2;
		sol = GlobalMembersCelemaia.minim(GlobalMembersCelemaia.dei(st, mid), GlobalMembersCelemaia.dei(mid + 1, dr));
		k = 0;
		for (int i = st;i <= mid;i++)
		{
			if (px[mid].x - px[i].x <= sol)
			{
				py[++k] = px[i];
			}
		}
		for (int i = mid + 1;i <= dr;i++)
		{
			if (px[i].x - px[mid].x <= sol)
			{
				py[++k] = px[i];
			}
		}
		sort(py + 1,py + k + 1,cmp2);
		for (int i = 1;i <= k;i++)
		{
			for (int j = 1;j <= 7 && j + i <= k;j++)
			{
//C++ TO JAVA CONVERTER WARNING: The following line was determined to be a copy constructor call - this should be verified and a copy constructor should be created if it does not yet exist:
//ORIGINAL LINE: sol=minim(sol,dist(py[i],py[i+j]));
				sol = GlobalMembersCelemaia.minim(sol, GlobalMembersCelemaia.dist(new data(py[i]), new data(py[i + j])));
			}
		}

		return sol;
	}

	public static int Main()
	{

//C++ TO JAVA CONVERTER WARNING: The right shift operator was not replaced by Java's logical right shift operator since the left operand was not confirmed to be of an unsigned type, but you should review whether the logical right shift operator (>>>) is more appropriate:
		fin >> n;
		for (int i = 1;i <= n;i++)
		{
//C++ TO JAVA CONVERTER WARNING: The right shift operator was not replaced by Java's logical right shift operator since the left operand was not confirmed to be of an unsigned type, but you should review whether the logical right shift operator (>>>) is more appropriate:
			fin >> px[i].x >> px[i].y;
		}
		sort(px + 1,px + n + 1,cmp1);
		fout << setprecision(6) << fixed << Math.sqrt(GlobalMembersCelemaia.dei(1, n)) << "\n";

		return 0;
	}
}