We need to find the minimum radius circle that encloses all given points. This is the smallest enclosing circle (also known as the minimum covering circle, or the smallest circle problem). For N up to 50, we can implement a classic algorithm: Welzl's algorithm (expected linear time) or simple O(N^4) brute force since N is small (50). But O(N^4) might be borderline but likely okay: 50^4 = 6.25e6, times constant for geometric calculations, which is fine. However we need to be careful with floating point precision, but double is fine.
But there is a simpler approach: The minimal enclosing circle is either determined by two points (diameter) or three points (circumcircle). So we can check all pairs and triples, compute the smallest circle that encloses all points, and take the minimum radius among those circles that cover all points. Actually, the minimum circle is uniquely defined and is determined by at most 3 points. So we can just consider all circles defined by (i) a circle with center at a point (radius 0) – not needed because need to cover all points; but the minimal circle might be defined by two points as diameter, or three points (circumcircle), or possibly one point if N=1 but N>=2. Also note that the minimal circle might have its center at one of the points? Actually, the minimal circle's center is not necessarily at a point; but it is defined by points on the boundary: either two points (the circle's diameter) or three points (non-collinear) on the boundary. However, also the circle might be determined by one point? If all points are same? But they are distinct. So we can consider all circles where the boundary passes through 1,2, or 3 points? The minimal circle for N>=2 must have at least two points on the boundary; if the circle is defined by three points, the boundary passes through three; if it's defined by two, they are opposite ends of a diameter. Could it be that the minimal circle has only one point on its boundary? Consider three points forming an acute triangle: the minimal circle is the circumcircle of the triangle, which passes through all three points, so three points on boundary. For an obtuse triangle, the minimal circle has the longest side as diameter, and the third point is inside; then the circle's boundary passes through the two endpoints of the diameter (two points). So indeed at least two points lie on the boundary. So checking all circles determined by pairs (as diameter) and triples (as circumcircle) yields candidate circles. Then for each candidate, we need to ensure it contains all points (i.e., distance <= radius). Then choose the smallest radius.
But careful: There is also possibility that the minimal circle is determined by one point? That would be if all points coincide, but they are distinct, so no. Also if N=2, minimal circle is the circle with the two points as diameter (or any circle with radius at least half the distance). The minimal radius is half the distance; indeed the circle with the segment as diameter has center at the midpoint, radius half distance. So checking all pairs as diameter gives that.
Thus algorithm: For each pair of points (i,j), define the circle with center at midpoint, radius = half distance. Check if all points are within radius (distance from center <= radius + epsilon?). Then for each triple (i,j,k) that are not collinear (or collinear but we can handle), compute the circumcircle. The circumcenter is intersection of perpendicular bisectors. The radius is distance from circumcenter to any of the three points. However, if the three points are collinear, the circumcircle is degenerate (infinite radius). So skip collinear triples. Also, if the triangle is obtuse, the circumcenter lies outside the triangle, but the circumcircle still exists. However, the minimal circle for an obtuse triangle is defined by the diameter, not the circumcircle (the circumcircle would be larger). So checking all triples includes both acute and obtuse triangles. For an obtuse triangle, the circumcircle radius will be larger than the half of longest side, so the minimal will be captured by the diameter pair. So we can just check all triples anyway. But there is nuance: The minimal circle could be determined by two points that are not the farthest apart? Actually if we have a set of points, the minimal circle is defined by the farthest pair? Not necessarily: For points on a circle, the minimal circle might be the circle that passes through three points, but if those three are not the farthest apart, maybe the diameter circle from the farthest pair would be larger? Example: three points forming an acute triangle: the circumcircle might be smaller than the circle with diameter as the longest side? Actually let's examine: For an acute triangle, the circumradius R = abc/(4K). The longest side's half is a/2. For an acute triangle, is R >= a/2? Actually by law of sines: a/sinA = 2R, so R = a/(2 sinA). Since A <= 90°, sinA <= 1, so R >= a/2. Equality when A=90°, then the triangle is right, and the circumcenter is midpoint of hypotenuse, so R = hypotenuse/2, which is exactly half the longest side. For acute triangle, all angles < 90°, so sinA < 1 for the largest angle? Actually if the largest angle is < 90°, then sin(largest angle) < 1, so for the side opposite that angle (which is the longest side), we have R = longest side / (2 sin(largest angle)) > longest side / 2. So indeed circumradius is larger than half the longest side. But wait: For an acute triangle, the minimal circle is the circumcircle, which is larger than the circle with the longest side as diameter. But does the circle with longest side as diameter cover all points? For an acute triangle, the third point lies inside the circle with diameter as longest side? Not necessarily: In an acute triangle, the third point may lie outside the semicircle? Actually Thales' theorem: points on a circle with diameter AB are such that angle ACB is right. For an acute triangle, all angles < 90°, so the point C would lie inside the circle with diameter AB if angle ACB > 90°? Wait, there's known fact: For a given segment AB, the set of points C such that angle ACB is acute/obtuse corresponds to inside/outside the circle with diameter AB. Specifically, if C is inside the circle with diameter AB, then angle ACB > 90° (obtuse). If C is on the circle, angle = 90°. If C is outside, angle < 90° (acute). Let's check: In a circle, the inscribed angle subtended by a diameter is a right angle. So if AB is diameter, any point C on the circle yields angle ACB = 90°. For points inside the circle, angle ACB > 90° (since arc is larger?). Actually, consider triangle with AB fixed and C variable. The angle at C is determined by distances. There is a known relation: In triangle ABC, angle ACB is obtuse if and only if AC^2 + BC^2 < AB^2? Actually for an angle at C, by law of cos: cos C = (AC^2+BC^2-AB^2)/(2BC). So angle C > 90° iff cos C < 0 iff AC^2+BC^2 < AB^2. Meanwhile, C lies inside the circle with diameter AB if its distance to the midpoint M satisfies CM < AB/2. But CM^2 = (AC^2+BC^2)/2 - AB^2/4 (by Apollonius). So CM < AB/2 iff (AC^2+BC^2)/2 - AB^2/4 < AB^2/4 => AC^2+BC^2 < AB^2. Indeed same condition. So C inside the circle with diameter AB iff AC^2+BC^2 < AB^2, which corresponds to angle C > 90° (obtuse). So for an acute triangle, all angles are < 90°, so each vertex is outside the circle with the opposite side as diameter. Therefore, for the longest side AB, the third point C lies outside the circle with diameter AB because angle ACB is acute (< 90°). So the circle with diameter AB does not cover point C. So we need larger circle. Thus indeed the minimal circle for an acute triangle is its circumcircle, which is larger than half the longest side.
Therefore, checking all pairs and triples yields the minimal circle.
But caution: There is also possibility that the minimal circle is defined by two points not forming a diameter? Actually the minimal circle boundary must pass through at least two points. If exactly two points, they must be antipodal points on the circle (i.e., center is midpoint). If they are not antipodal, the circle could be adjusted to reduce radius while still covering them? Let's think: Suppose we have a set of points, and the minimal circle has exactly two points on its boundary, but they are not opposite ends. Could that happen? Consider three points: two points on boundary and one interior. The circle's center is on the perpendicular bisector of those two points. To minimize radius while covering the interior point, the center moves along that line until the distance to one of the boundary points equals distance to the interior point (if the interior point becomes boundary as well, then three points). But if only two points remain on boundary, the interior point is strictly inside. But if only those two are on boundary, then the center must be such that the two boundary points are at equal distance (radius) and all others <= radius. For a given pair of boundary points, the radius is distance from center to one of them. For a fixed pair, the minimal radius that covers all points is the minimum over centers on the perpendicular bisector such that max(dist(center, boundary point), distances to other points) is minimized. This is a 1D minimization. The optimal center is somewhere on that line. But is it possible that the optimal circle has exactly two boundary points and they are not diametrically opposite? In that case, the center is not the midpoint. However, the standard result of smallest enclosing circle states that it is uniquely determined and either has two points that are antipodal (i.e., the center is the midpoint) OR has three points on the boundary (which define the circumcenter). Wait, let's recall known facts: The smallest enclosing circle (also called minimum covering circle) has the property that it is determined by either two points which are opposite ends of a diameter of the circle, or three points on the boundary which form an acute triangle and the circle is their circumcircle. Actually, the two-point case: If the minimal circle is determined by two points, then those two points must be at opposite ends of a diameter. Because if they are not opposite, then you could rotate/shift the circle to reduce radius while keeping them on boundary? Let's verify: For two points A and B on the boundary, the center O must satisfy OA = OB = R. So O lies on perpendicular bisector of AB. For the circle to be minimal covering all points, moving O along the bisector changes R (since R = distance from O to A). Actually R = sqrt( (AB/2)^2 + d^2 ) where d is distance from O to the midpoint M. So R increases as |d| increases; the minimal R for a given pair is when d=0, i.e., center at midpoint, giving R = AB/2. But then the two points are opposite ends? Actually if center at midpoint, then AB is a diameter? The diameter is 2R = AB, so yes, AB is a diameter. So if the minimal circle has exactly two boundary points, it must be that the center is the midpoint of those two points; otherwise we could move the center to midpoint and reduce R while still covering? But does moving to midpoint keep all points inside? Possibly some point that was inside may become outside if we reduce radius. But if we move the center to midpoint, the radius becomes AB/2. But maybe some other point that was exactly at distance R from the original center becomes > AB/2 from the midpoint, so the circle with midpoint may not cover all points. However, we could then enlarge the radius to cover that point, but then the boundary points might not be exactly those two. The minimal covering circle is the minimal radius over all circles covering points. So if there is a circle with two boundary points not diametral, we could consider the circle with center at midpoint of those two and radius = AB/2. That circle might not cover all points. But maybe there exists a covering circle with radius less than AB/2? No, AB/2 is the minimal possible radius for a circle that has both A and B on its boundary? Actually, any circle that passes through A and B must have radius at least AB/2, because the chord length AB is at most the diameter (2R). So R >= AB/2, with equality only if AB is a diameter. So a circle that passes through A and B and has R > AB/2 can have center not at midpoint. But the minimal covering circle might have R > AB/2 if needed to cover other points. However, if the minimal covering circle has exactly two boundary points A and B, then the center must be on the perpendicular bisector, and R = distance from O to A. Could there be a situation where the minimal covering circle has exactly two boundary points A and B but the center is not the midpoint? Suppose we have three points: A and B on boundary, and C inside but close to the perpendicular bisector. If we move O to midpoint, R becomes AB/2, but C might be outside this smaller circle? Actually if C is inside the original circle with center O (not midpoint), moving the center to midpoint reduces R, and could cause C to be outside. However, the minimal covering circle is defined as the smallest radius circle that covers all points. If we try to reduce radius by moving center, we might need to increase radius later. The known result is: The minimal enclosing circle is determined either by two points that are antipodal (i.e., the segment is a diameter) or by three points on the boundary. This is a classic result: The smallest enclosing circle is unique, and its boundary contains either two or three points. If two, they are opposite ends of a diameter; if three, they form an acute triangle. So we can rely on that. So indeed checking circles with diameter (pairs) and circumcircles (triples) is sufficient.
Thus we can implement brute force: For all i<j: compute center = ((x_i+x_j)/2, (y_i+y_j)/2), radius = distance/2. Check all points, if max distance <= radius+epsilon, record radius. For all i<j<k: compute circumcenter and radius. If the three points are collinear, skip (or treat as infinite radius, but we can skip). For triangle, compute circumcenter. Use formula: For points A, B, C. Let D = 2*(ax*(by-cy)+bx*(cy-ay)+cx*(ay-by)). If D=0 (collinear), skip. Then Ux = ((ax^2+ay^2)(by-cy) + (bx^2+by^2)(cy-ay) + (cx^2+cy^2)(ay-by))/D; Uy = ((ax^2+ay^2)(cx-bx) + (bx^2+by^2)(ax-cx) + (cx^2+cy^2)(bx-ax))/D. Then radius = sqrt((ax-Ux)^2+(ay-Uy)^2). Then check all points. Keep minimal radius.
Since N <= 50, pairs = about 1225, triples = about 19600. So about 20k circles to check, each requiring checking distances to N points (50) -> about 1e6 distance computations, which is trivial.
But careful: The minimal circle might also be determined by a single point? For N=1, but N>=2, so ignore. Also, there is possibility that the minimal circle is determined by three points where one of them is exactly inside? Actually the three points should be on boundary, but our circumcircle will include them exactly. But if the three points are collinear or the triangle is degenerate, skip.
Edge Cases: All points collinear. Then the minimal circle is the smallest circle covering all points, which is essentially the circle whose diameter is the farthest pair. Indeed, the minimal circle for collinear points is the circle with the segment between the two extreme points as diameter. Our algorithm: For collinear points, any triple will be collinear and skipped. The pair check will capture the farthest pair's diameter (since we check all pairs, the minimal radius that covers all points will be half the maximum distance among any pair). But is that always the minimal? Suppose three collinear points A, B, C with A and C farthest; the circle with diameter AC will cover B because B lies on the segment AC, and any point on the segment is inside the circle with diameter AC? Actually check: For points on line, the circle with diameter AC: The set of points inside that circle is the disk. Does the midpoint of AC lie inside? Yes. But does an intermediate point B at coordinate between A and C lie inside the circle? Let's test: A=(0,0), C=(2,0), B=(1,0). Circle with center (1,0) radius=1. B is at center? Actually B at (1,0) is center, so inside. So yes, all points on segment are inside. Actually, for any point on the segment, its distance to the center (midpoint) is <= half the length, so it's inside. So indeed the circle with diameter endpoints covers all collinear points. So pair check works.
But what about points that are not collinear but the minimal circle might be defined by two points that are not the farthest pair? Possibly. Consider points that are almost collinear but with a slight offset. The minimal circle might be defined by two points that are not the farthest apart? But if the minimal circle is determined by two points, those two must be opposite ends of a diameter, and they are the farthest apart among the set? Not necessarily: Could there be a set where the minimal circle uses a pair that is not the farthest distance? Suppose we have three points: A, B, C forming an obtuse triangle with AB longest. Then the minimal circle is the circle with diameter AB. AB is the longest side. So indeed the diameter pair is the farthest apart. Could there be a case where the minimal circle uses two points that are not the farthest? Consider four points: Suppose we have three points forming an acute triangle, and a fourth point far away. Then the minimal circle might be defined by the far away point and some other point as diameter? Actually if there is a far away point, the farthest pair might be two extreme points, and the minimal circle would be defined by that farthest pair or maybe a circumcircle of three including that far point. But the farthest pair often is the one that determines the diameter. However, it's possible that the minimal circle is determined by two points that are not the farthest apart if there are three boundary points? Actually if the minimal circle has three points on boundary, those three might not include the farthest pair. But if it has two points, they must be antipodal; could that pair be not the farthest? Consider points that lie on a circle. The minimal circle is the circle itself, which has many boundary points. But the minimal circle determined by two points as diameter would be a different (larger?) Not relevant. For minimal covering circle, suppose we have points: A and B close together, and C far away. The farthest pair is between C and either A or B. The minimal circle must cover C. The circle with diameter AB would not cover C because AB is small. So the minimal must involve C. The circle with diameter AC (or BC) will have radius half of AC. Could that be minimal? Possibly if AC is the farthest distance. But if there is a point D such that CD is larger than AC, then half CD would be larger, so the minimal might be defined by the farthest pair. But if there is a point D that is even farther from C, then the farthest pair is CD, and half CD would be larger than half AC, so the minimal circle might actually be the circumcircle of three points that yields a radius smaller than half of the farthest distance? Could that happen? Consider points arranged such that the farthest distance is between two points, but the minimal covering circle might be smaller than half of that distance if we use three points? That seems impossible because any circle that covers all points must have a diameter at least the farthest distance (i.e., the circle's diameter must be at least the maximum distance between any two points). Since the circle's diameter is 2R, we have 2R >= max distance, so R >= (max distance)/2. Therefore, the minimal radius cannot be less than half the farthest distance. So the minimal radius is at least half the farthest distance. So if we find a circle with radius less than half the farthest distance, it cannot cover those two farthest points. Thus the minimal radius is at least half the farthest distance. So the two-point circle defined by the farthest pair gives a radius exactly half the farthest distance. But is it always covering? Not always: half the farthest distance circle might not cover all points if the farthest pair is not the diameter of the covering circle? Wait, consider two farthest points A and Z. The distance d = |AZ|. The circle with center at midpoint of AZ and radius d/2 will cover A and Z exactly on boundary. But it may not cover some other point P if P lies outside that circle. That would mean that the maximum distance constraint is not sufficient; we need a larger radius. So the minimal radius could be > d/2. Therefore, the diameter of the minimal circle (2R) is at least d, but could be larger. So the farthest distance gives a lower bound, not an upper bound.
But the pair circle that we check for each pair uses radius = half the distance between that pair. For the farthest pair, that radius is the largest among pair radii? Actually half the distance: for larger distances, half is larger. So the farthest pair gives the largest half-distance among all pairs. But we are looking for the minimal radius circle that covers all points. So we might need a circle larger than the half of some pair? Actually we want minimal radius, so we consider all circles, and the minimal one may have radius larger than half the farthest distance? Wait: The minimal radius must be at least half the farthest distance. So the minimal possible radius cannot be less than half of the maximum pair distance. That is a lower bound. But we are scanning candidate circles; some circles may have radius equal to half of some pair distance (like a pair circle). For that pair, if it's not the farthest pair, its half-distance is smaller than the lower bound, so such a circle cannot possibly cover all points because the farthest pair distance is larger than the diameter of that circle? Actually if we have a circle of radius R, then any two points must satisfy distance <= 2R (by triangle inequality: distance between two points <= distance from each to center sum <= R+R = 2R). So the condition is: 2R >= max pair distance. So if we take a circle defined by a pair with distance d, its radius R = d/2. For this circle to cover all points, we need that for all other pairs, distance <= 2R = d. But the farthest pair distance may be > d, then the condition fails. So indeed any pair circle that is not from the farthest pair will have radius less than half of the farthest distance, so it will fail to cover the farthest pair. Thus only the pair circle from the farthest pair can possibly be a candidate (and even that may fail if some other point lies outside). However, there may be pair circles from non-farthest pairs that still have radius larger than half of the farthest distance? That cannot happen because half of a smaller distance is smaller. So the only pair circle that might be feasible is the one from the farthest pair (the pair with maximum distance). But is it possible that two different pairs have the same maximum distance? If there are multiple farthest pairs, then checking all pairs covers them anyway. So we could restrict to only the farthest pair(s). But the classic algorithm of checking all pairs still works, because others will be eliminated early as not covering all points. That's okay.
But there is nuance: The minimal circle might have radius exactly equal to half the farthest distance if the farthest pair are antipodal on that circle. That's the two-point case. So indeed the pair circle from the farthest pair is the only candidate among pairs, but we check all pairs anyway for simplicity.
Now for triples: They can produce radius larger than half the farthest distance (since for any triangle, circumradius >= half the longest side, with equality for right triangle). So they may be larger than half the farthest distance, but might still be the minimal if the farthest pair circle fails to cover all points. So we need to consider both.
Thus our brute-force approach is correct.
Implementation steps:
Read N, and arrays xs, ys.
Initialize answer = infinity.
For each i in range(N):
For each j in range(i+1, N):
Compute center_x = (xs[i] + xs[j]) / 2.0
center_y = (ys[i] + ys[j]) / 2.0
radius = hypot(xs[i]-xs[j], ys[i]-ys[j]) / 2.0
# Check if all points are within radius (including points i,j: they are exactly on boundary, so within due to equality)
# Use <= with some epsilon maybe 1e-12 to avoid precision issues.
# If max distance <= radius (or <= radius + eps), then update ans = min(ans, radius)
For each i in range(N):
For each j in range(i+1, N):
For each k in range(j+1, N):
Compute circumcenter and radius.
Avoid degenerate (collinear). Use formula with D = 2*(ax*(by-cy) + bx*(cy-ay) + cx*(ay-by)). If |D| < epsilon (like 1e-12), skip.
Compute Ux, Uy using formula.
radius = hypot(ax-Ux, ay-Uy)
Check all points: compute dist from (Ux,Uy) to each point. If all distances <= radius + eps, update ans.
After loops, print ans with high precision.
Edge Cases: N=2: only pairs considered, ans will be half distance.
N=3 acute: pair circles will be from each pair; the pair from longest side will have radius half of that, but that circle won't cover the third point (since acute triangle), so check fails. Only the circumcircle of the triangle will succeed, and that will be minimal. However, note that for an acute triangle, the circumcircle covers all points. So ans will be that.
But also we must consider that the circumcircle of three points might also be computed even if the triangle is obtuse; then the circumcircle will have radius > half the longest side. The circle might still cover all points? For an obtuse triangle, the circumcenter lies outside the triangle, but the circumcircle still includes all three vertices. So it covers them. However, the minimal circle for an obtuse triangle is the circle with the longest side as diameter, which has radius = half the longest side, which is smaller than the circumradius. But our algorithm will also check the pair circle from the longest side, which will succeed? Actually for an obtuse triangle, does the circle with diameter as the longest side cover the third point? As argued earlier, for obtuse triangle, the angle opposite the longest side is > 90°, so the third point lies inside the circle with that diameter (since condition AC^2+BC^2 < AB^2). So the pair circle covers all three points. So the minimal radius will be the half of longest side. The algorithm will find that when checking that pair. The circumcircle will have larger radius, so ans will be the smaller from the pair. So it's fine.
Potential issues: For floating point comparisons, we should use a small epsilon to account for rounding errors. For checking if a point is inside or on the circle, we should check distance <= radius + 1e-9 or something. But since we compute circles from points, the boundary points should be exactly within radius. However, due to floating point, the computed radius might be slightly different from the actual distance to those defining points. For the pair circle, radius = half of distance, and center is midpoint. The distance from center to one of the defining points is exactly half the distance? In floating point, it should be very close. But we compute radius using hypot on differences, then divide by 2. For the distance from center to point i: we compute sqrt((x_i - cx)^2 + (y_i - cy)^2). Ideally, that should equal radius. But due to rounding, it might differ slightly. So we should allow tolerance: if dist <= radius + 1e-12, consider inside.
Similarly for circumcenter: the formula may produce rounding errors, so the computed radius may not exactly equal distances to the three vertices due to numeric error. So we need to check with tolerance.
Also, for degenerate (collinear) triples we skip if |D| < epsilon.
But wait: N <= 50, but we also need to consider that the minimal circle might be defined by a single point? Already covered. Also, what about circles defined by one point and radius zero? Not needed.
One more nuance: Could the minimal circle be defined by two points but the center not at midpoint? The classic result says no. So fine.
Thus this approach yields the correct answer.
However, is there any case where the minimal circle is not captured by checking all pairs and triples? There is a classic approach: The minimum enclosing circle can be found by starting with an arbitrary circle and incrementally adding points. But our brute force covering all candidate circles is known to be correct because the minimal circle is uniquely determined by either two or three points on the boundary. So if we check all subsets of size 2 and 3, we must encounter the circle that is the minimal enclosing circle. But careful: The circle defined by three points (circumcircle) may not be the minimal enclosing circle even if those three points are on its boundary; but the minimal enclosing circle must be either a circle with two points as diameter or the circumcircle of three points. But is it guaranteed that the circle defined by those three points (their circumcircle) is the minimal enclosing circle for the whole set? Not exactly; it could be that the minimal circle has three points on the boundary, but not all triples of boundary points necessarily define that circle? Actually, if the minimal circle has three points on its boundary, then those three points uniquely determine the circle (the circumcircle). So the circle is exactly the circumcircle of those three points. Therefore, if we examine all triples, we will examine that triple and compute its circumcircle. That circle will contain the three points on its boundary and must contain all other points (since it is the minimal enclosing circle). So it will be a valid covering circle, and its radius is the minimal. So we will capture it.
But what if the minimal circle has exactly two points on its boundary? Then it is the circle with those two points as diameter. So we will capture it via that pair.
Thus brute-force is correct.
But we must also consider the possibility that the minimal circle has more than three points on the boundary (e.g., square's minimal enclosing circle is the circumcircle of the square, which has four points on boundary). In that case, any three of those four points (if they are not collinear and not all three are a right triangle? Actually for a square, the minimal circle is the circle circumscribing the square; its center is the square's center, radius = half diagonal. The boundary contains all four vertices. Are there three of these vertices whose circumcircle is the same as the circle of the square? For a square, the circumcircle of any three vertices (unless they are three vertices that are not all corners? For a square, any three vertices are not collinear. The circumcircle of three vertices of a square: If we pick three vertices that include both ends of a diagonal? Let's test: Square with vertices (0,0), (1,0), (1,1), (0,1). The minimal circle is centered at (0.5,0.5), radius sqrt(2)/2 ≈ 0.7071. If we pick vertices (0,0), (1,0), (1,1), these three points form a right triangle (right angle at (1,0)? Actually coordinates: (0,0)-(1,0)-(1,1): lengths: 1, sqrt(2), 1. It's a right triangle with hypotenuse from (0,0) to (1,1) length sqrt(2). Its circumcenter is midpoint of hypotenuse (0.5,0.5), radius = sqrt(2)/2. So yes, that triple yields the correct circle. Similarly, any three vertices that include the diagonal endpoints will produce the same circle. If we pick three vertices that do not include both ends of a diagonal, e.g., (0,0), (1,0), (0,1): this is also a right triangle with hypotenuse from (1,0) to (0,1) length sqrt(2), circumcenter at (0.5,0.5). So all triples of vertices of a square that are not collinear actually give the same circumcircle? Let's check (0,0),(1,0),(0,1) works. (0,0),(1,1),(0,1): points (0,0),(1,1),(0,1): distances: (0,0)-(1,1)=sqrt2; (0,0)-(0,1)=1; (1,1)-(0,1)=1. This is an isosceles triangle, the circumcenter? Might be (0.5,0.5) as well? Let's compute: The perpendicular bisectors: For (0,0)-(1,1) midpoint (0.5,0.5), slope of segment =1, so perpendicular slope -1, line: y-0.5 = -1(x-0.5) -> y = -x+1. For (0,0)-(0,1) midpoint (0,0.5), vertical segment, perpendicular is horizontal line y=0.5. Intersection: y=0.5, then 0.5 = -x+1 => x=0.5. So yes (0.5,0.5). So all triples give the same circumcenter? Actually any three points on a circle will have the same circumcircle only if they are all on the same circle. For four points on a circle, any three will determine that circle uniquely. So indeed any triple of boundary points will produce the minimal circle. So checking all triples will find it.
Thus brute-force works.
Implementation details: Use double. Epsilon for collinearity: maybe 1e-9. For inclusion: dist <= radius + 1e-9.
Potential pitfalls: The circumcenter formula can be numerically unstable for nearly collinear points, but with N=50 and integer coordinates up to 1000, it's fine.
Alternative approach: Use Welzl's algorithm for robustness, but brute force is simpler.
Now we must output the answer with high precision (error <= 1e-6). So printing with say 15 decimal digits is fine.
Let's test with provided examples.
Example 1:
2 points (0,0) and (1,0). Pair circle: center (0.5,0), radius=0.5. That's ans=0.5. Triples none. Output 0.5.
Example 2:
3 points (0,0),(0,1),(1,0). This is right triangle? Actually (0,0)-(0,1) length 1, (0,0)-(1,0) length 1, (0,1)-(1,0) length sqrt2. So it's right angle at (0,0). Minimal circle is circumcircle with hypotenuse as diameter, radius = sqrt2/2 ≈ 0.70710678. Our algorithm: Check pairs: The longest distance is sqrt2 ≈1.414, half ≈0.7071. Circle with that diameter (between (0,1) and (1,0)): center (0.5,0.5) radius 0.7071. Check all points: distance from center to (0,0) = sqrt(0.5^2+0.5^2)=0.7071 = radius, so inside/on. So this pair circle works. Also other pairs: (0,0)-(0,1) radius 0.5 fails because distance to (1,0) from center (0,0.5) = sqrt(1^2+0.5^2)=~1.118>0.5. (0,0)-(1,0) radius 0.5 fails similarly. So ans from pairs is 0.7071. Triples: circumcircle of all three: compute, will give same center and radius, so ans same. So output matches.
Example 3: Some set of 10 points, we trust.
Thus solution is straightforward.
But is there any chance that the minimal circle is determined by a single point? Not for N>=2 distinct.
One more nuance: For points where all pairs circles fail, but some triple circle succeeds. That will be captured.
Thus we can implement.
Now code: in Python.
Implementation plan:
def dist2(x1,y1,x2,y2): (x1-x2)**2 + (y1-y2)**2.
To avoid sqrt for comparisons, we can compare squared distances. However, radius is a sqrt, and we need to compare distances <= radius. It's easier to compute sqrt distances, but for many checks we could compute squared distances and compare to radius^2. That might be faster and avoid repeated sqrt. For each candidate circle, we can compute radius_sq = radius**2? But careful: radius is computed via sqrt for pair circle: radius = distance/2, so radius_sq = (dx^2+dy^2)/4. For triple, radius_sq = (ax-Ux)^2+(ay-Uy)^2. So we can compute radius_sq directly and avoid sqrt until final answer. But we need to output radius, so we can compute radius = sqrt(radius_sq) at the end. For comparisons: check for each point: (x - cx)^2 + (y - cy)^2 <= radius_sq + eps (but careful about epsilon in squared terms). Since we will have sqrt anyway at the end, we can keep radius as sqrt and compute distances with sqrt, but sqrt per check (50~20k = 1M) is okay in Python? 1M sqrt might be a bit heavy but still fine (<0.1 sec?). Actually 1M sqrt in Python may be around 0.05-0.1 seconds? Possibly acceptable. But to be safe we can avoid sqrt in inner loops by using squared distances and comparing to radius_sq. But then we need to compute radius_sq accurately without sqrt. For pair: dx = xi-xj, dy = yi-yj; radius_sq = (dxdx+dy*dy)/4.0. For triple: compute Ux, Uy, then radius_sq = (ax-Ux)^2+(ay-Uy)^2. Good.
We'll store best radius (actual float). But we can keep best radius as minimal sqrt(radius_sq) after verifying coverage. So we can compute candidate radius = sqrt(radius_sq) only if it is less than current best (or compute at end). Actually we can compute radius = sqrt(radius_sq) after verifying coverage, but to verify coverage we need to compare distances to radius_sq. So we can first compute radius_sq, then check all points: if squared distance > radius_sq + eps, then invalid. If passes, compute radius = sqrt(radius_sq) and update best = min(best, radius). This avoids sqrt for many checks that fail early? We'll compute radius_sq anyway; sqrt only for valid circles.
But we need epsilon: For squared comparisons, if we use epsilon like 1e-9, but squared distances and radius_sq may be large up to (1000√2)^2/4? Actually max distance between points can be up to sqrt((1000)^2+(1000)^2) ≈ 1414, so radius_sq up to (1414/2)^2 ≈ 500,000? Actually (1414^2)/4 ≈ 2e6/4=500,000. So numbers are moderate.
We can set EPS = 1e-9 for collinearity check (using cross product). For inclusion, because of floating errors, we might add a small tolerance. Since we compute using double, we can use EPS = 1e-9 for squared comparison: if dist_sq > radius_sq + 1e-9 then outside. But because we compute radius_sq exactly from differences, and distances from center also computed from differences, the error should be within machine epsilon. However, for circumcenter, there might be larger error. So a small epsilon like 1e-9 is safe.
Better: Use a relative epsilon? But absolute is fine because coordinates are integers up to 1000 and distances up to ~1e3, errors are small.
Thus algorithm:
N = int(input())
pts = [tuple(map(int, input().split())) for _ in range(N)]
Initialize best = float('inf')
pairs
for i in range(N):
xi, yi = pts[i]
for j in range(i+1, N):
xj, yj = pts[j]
dx = xi - xj
dy = yi - yj
radius_sq = (dxdx + dydy) / 4.0
cx = (xi + xj) / 2.0
cy = (yi + yj) / 2.0
# check coverage
ok = True
for (x, y) in pts:
d2 = (x - cx)(x - cx) + (y - cy)(y - cy)
if d2 > radius_sq + 1e-9:
ok = False
break
if ok:
best = min(best, math.sqrt(radius_sq))
triples
for i in range(N):
xi, yi = pts[i]
for j in range(i+1, N):
xj, yj = pts[j]
for k in range(j+1, N):
xk, yk = pts[k]
# check collinearity
# Compute area * 2? Actually D = 2*(ax*(by-cy)+...)
D = 2.0 * (xi*(yj - yk) + xj*(yk - yi) + xk*(yi - yj))
if abs(D) < 1e-12:
continue
# compute circumcenter
# using formula with squared distances
# Ux = ( (xi^2+yi^2)(yj-yk) + (xj^2+yj^2)(yk-yi) + (xk^2+yk^2)(yi-yj) ) / D
# Uy = ( (xi^2+yi^2)(xk-xj) + (xj^2+yj^2)(xi-xk) + (xk^2+yk^2)(xj-xi) ) / D
# Actually careful: The formula: Ux = ( ( (x_i^2 + y_i^2) * (y_j - y_k) + (x_j^2 + y_j^2) * (y_k - y_i) + (x_k^2 + y_k^2) * (y_i - y_j) ) ) / D
# Uy = ( ( (x_i^2 + y_i^2) * (x_k - x_j) + (x_j^2 + y_j^2) * (x_i - x_k) + (x_k^2 + y_k^2) * (x_j - x_i) ) ) / D
# Yes.
xi2yi2 = xixi + yiyi
xj2yj2 = xjxj + yjyj
xk2yk2 = xkxk + ykyk
code
Ux = (xi2yi2 * (yj - yk) + xj2yj2 * (yk - yi) + xk2yk2 * (yi - yj)) / D
Uy = (xi2yi2 * (xk - xj) + xj2yj2 * (xi - xk) + xk2yk2 * (xj - xi)) / D
# radius_sq = distance from U to any of the three points, say i
dx = xi - Ux
dy = yi - Uy
radius_sq = dx*dx + dy*dy
# check coverage
ok = True
for (x, y) in pts:
d2 = (x - Ux)*(x - Ux) + (y - Uy)*(y - Uy)
if d2 > radius_sq + 1e-9:
ok = False
break
if ok:
best = min(best, math.sqrt(radius_sq))
print("{:.15f}".format(best))
But need to import math.
Edge Cases: Could there be a case where no circle is found? That would happen only if N=0, but N>=2. Our algorithm will always find at least the circle from the farthest pair? Not necessarily: The farthest pair circle might not cover all points, so it might be invalid. But then we must have some triple circle that covers all? Is it guaranteed that there exists a triple circle that covers all? For any set of points, the minimal enclosing circle exists and is either a pair circle or a triple circle. So if we check all pairs and triples, at least one will be valid: the minimal circle itself. So we will find it. But there is a subtlety: Our triple loop skips collinear triples. If the minimal circle is determined by two points (pair circle), that will be found. If it is determined by three points, those three cannot be collinear (since they define a circle). So it will be considered. So at least one candidate will be valid.
Double-check: For a set of points that are all collinear, the minimal circle is a pair circle (the farthest endpoints). So it will be found.
Thus algorithm works.
Potential performance: 19600 triples, each checking 50 points, that's 980k distance squared calculations, each with a few operations, fine.
Now we must ensure that we don't miss the case where the minimal circle is defined by two points but the center is not the midpoint? According to classical theory, it must be midpoint. So fine.
But wait: There is a nuance: In the two-point case, if the two points are exactly opposite ends of the diameter, then the circle is defined. However, suppose we have a set of points where the minimal circle has exactly two points on its boundary, but those two points are not antipodal? Could it happen? Let's attempt to construct: Suppose we have points A and B on the boundary. The center O is somewhere on the perpendicular bisector. The radius R = OA = OB. If we try to move O along the bisector towards A, R increases? Actually distance from O to A is sqrt((AB/2)^2 + d^2) where d is distance from midpoint M to O. So R increases with |d|. So the minimal possible R for covering A and B is when d=0, i.e., R_min = AB/2. But if we have other points that force the center to be away from M, then the minimal R might be > AB/2. However, then the circle would have those two points still on the boundary? But if we move O, then A and B are still on boundary because OA = OB = R (by definition). But then the radius R > AB/2. Could the minimal covering circle have exactly two boundary points with center not at midpoint? Consider three points: A, B, and C such that C lies on the perpendicular bisector but outside the circle with diameter AB. If we take the circle with center at M (midpoint), R = AB/2, C is outside (since it's outside that circle). To cover C, we need to increase radius. If we move O along the perpendicular bisector towards C, we can increase the radius while keeping A and B on the boundary? Actually if we move O away from M, the distances to A and B increase, so they remain on the boundary if we set radius equal to that distance. But then we need to ensure C is inside. As we move O along the bisector towards C, the radius becomes larger. At some point, C might become inside. At that point, we have a circle with A and B still on the boundary, and C inside. This could be a candidate for minimal circle. However, is it possible that this circle is indeed the minimal covering circle? Let's examine with a concrete example: A = (0,0), B = (2,0). So M=(1,0). Let C = (1, 1). The circle with diameter AB (center M, radius 1) does not cover C because distance from M to C is 1, exactly? M to C = sqrt((1-1)^2+(0-1)^2)=1, which is equal to radius? Actually radius=1, so C is on the boundary? Wait distance from M to C is 1, so C lies on the circle? That would mean C is on the circle with center M radius 1. Is (1,1) at distance 1 from (1,0)? Yes, so C lies on that circle. So it's covered. But to get a scenario where C is outside: let C = (1, 1.5). Then distance from M to C = 1.5 > 1, so C outside. Now can we find a circle that passes through A and B and also encloses C? Let O be on the perpendicular bisector (x=1 line). Let O = (1, t). Then OA = sqrt((1-0)^2+(t-0)^2) = sqrt(1 + t^2). That's radius R. Distance from O to C = sqrt((1-1)^2+(t-1.5)^2) = |t-1.5|. We need |t-1.5| <= R = sqrt(1+t^2). Solve: For t < 1.5, |t-1.5| = 1.5 - t. So condition: 1.5 - t <= sqrt(1+t^2). Square both sides? We need to find t that satisfies. Let's find t that minimizes R while satisfying this. Actually we want minimal R that covers all. This is an optimization: minimize R = sqrt(1+t^2) subject to (1.5 - t) <= sqrt(1+t^2). The constraint ensures C inside. For t negative? Possibly. But note: R increases with |t|, so the minimal R would be when t is as small as possible? Actually sqrt(1+t^2) is minimal at t=0 (R=1). At t=0, constraint: 1.5 <= 1? false. So we need larger t? As t increases, sqrt(1+t^2) increases, and (1.5 - t) decreases. At t=0.5, R~ sqrt(1+0.25)=1.118, constraint: 1.5-0.5=1 <=1.118 true. So t=0.5 works. At t=0.5, radius sqrt(1+0.25)=1.118, constraint: 1.5 - (-0.5)=2 <=1.118 false. So negative t makes constraint worse. So optimal t likely positive. To minimize R, we can set the constraint as equality: 1.5 - t = sqrt(1+t^2). Solve: (1.5 - t)^2 = 1 + t^2 => (2.25 - 3t + t^2) = 1 + t^2 => 2.25 - 3t = 1 => 3t = 1.25 => t = 0.4166667. Then R = sqrt(1 + t^2) = sqrt(1 + 0.17361) = sqrt(1.17361) = 1.08333. So the minimal circle that covers A, B, C while having A and B on boundary has center at (1, 0.4166667) radius ~1.08333. Check if that circle is indeed the minimal covering circle for these three points? The farthest distance between points: AB=2, AC? A (0,0) to C (1,1.5): sqrt(1+2.25)=sqrt(3.25)=1.8028, BC: (2,0) to (1,1.5): sqrt(1+2.25)=1.8028. So half the farthest distance = 1. So that circle radius 1 doesn't cover C. The circumcircle of triangle ABC: compute coordinates. Points: A(0,0), B(2,0), C(1,1.5). Compute circumcenter: Midpoint of AB is (1,0), slope 0, perpendicular vertical line x=1. Perpendicular bisector of AC: A(0,0)-C(1,1.5), midpoint (0.5,0.75), slope of AC = 1.5, so perpendicular slope = -2/3? Actually slope = (1.5)/1 = 1.5, so perpendicular slope = -1/1.5 = -2/3. Equation: y-0.75 = -2/3 (x-0.5). Intersection with x=1: y-0.75 = -2/3 (0.5) = -1/3 => y = 0.75 - 0.33333 = 0.4166667. So circumcenter = (1, 0.4166667), radius = distance to A = sqrt(1^2 + 0.4166667^2) = sqrt(1+0.173611)=1.08333. So indeed the circumcircle of ABC is that circle. So the minimal circle for these three points is the circumcircle, because it covers all and is minimal. And it has all three points on boundary? Check: A and B: are they on boundary? Distance from center to A: sqrt(1^2 + 0.4166667^2)=1.08333 = R; B: (2,0) distance: sqrt((2-1)^2 + (0-0.4166667)^2)= sqrt(1 + 0.173611)=1.08333 = R; C: (1,1.5) distance: sqrt(0^2 + (1.5-0.4166667)^2)=1.08333 = R. So all three are on the boundary. That's interesting: In this triangle, all three points lie on the circle? That's the definition of circumcircle. So indeed the triangle ABC is not obtuse? Let's check angles: AB=2, AC=~1.8028, BC=~1.8028. Using law of cos: cos(C) = (AC^2+BC^2-AB^2)/(2BC) = (3.25+3.25-4)/(21.8028) = (2.5)/(6.5) ≈ 0.3846 => angle C ≈ 67.4° < 90°. Similarly, other angles: angle A and B? Compute cos(A) = (AB^2+AC^2-BC^2)/(2AC) = (4+3.25-3.25)/(21.8028) = (4)/(7.2112)=0.5547 => angle A ≈ 56.3°, angle B similar. So triangle is acute. Therefore, the minimal circle is the circumcircle, with all three points on boundary. So this is a three-point case. So indeed our algorithm captures this as a triple.
But what about a scenario where the minimal circle has exactly two points on the boundary, but the center is not the midpoint? As argued, if exactly two points are on the boundary, then the third point (if any) is inside. Could we have a minimal circle with exactly two boundary points but center not at midpoint? Let's try to conceive: Suppose we have points A, B, C such that C lies strictly inside the circle determined by A and B as diameter? Then the circle with diameter AB covers all three. That circle has A and B on boundary and center at midpoint. But is there any alternative circle with A and B on boundary but a different center that also covers C and has a smaller radius? No, because the radius for any center on the perpendicular bisector is sqrt((AB/2)^2 + d^2), which is larger than AB/2 if d != 0. So the radius would be larger, not smaller. So the minimal radius covering all points when the two boundary points are A and B would be at least AB/2, with the minimum achieved at midpoint. But if the midpoint circle fails to cover C (i.e., C is outside), then we must increase radius, which means the center moves away from midpoint, resulting in larger radius. In that case, the minimal covering circle might have all three points on boundary (if C becomes boundary as well) or maybe still only two if the optimal center results in C being inside but not on boundary? But if we increase radius by moving center, the distances to A and B increase, so they remain on boundary if we set radius equal to that distance. C's distance might become equal at some point, making it boundary. So the optimal center that minimizes max(OA, OC) while maintaining OA=OB is achieved when OA = OC (assuming C lies on the same side of the bisector). This yields three points on boundary. Because if we have two points A, B and a third point C, the minimal circle that covers all three and has A and B on boundary is either the midpoint circle if C inside, or a circle where C is also on boundary if C is outside the midpoint circle. That is, the minimal circle for three points is either the diameter circle if the triangle is obtuse, or the circumcircle if it's acute or right. In obtuse case, the circumcenter lies outside the triangle and the circle with diameter of the longest side is actually smaller and has only two points on boundary (the endpoints of the longest side). But does that circle have its center at the midpoint? Yes. So in obtuse case, the minimal circle is the pair circle, with center at midpoint. So again, exactly two boundary points implies center at midpoint. So the classic result stands.
Thus our algorithm is sound.
One more check: For N > 3, the minimal circle might be defined by two points that are not the farthest? Could that happen? Suppose we have many points, the minimal circle may be defined by two points that are not the farthest pair. But as argued, if it's a two-point case, those two are antipodal (diameter). Then any other point must be within that circle. In particular, the farthest distance between any two points cannot exceed the diameter = 2R. Since R is determined by that pair's distance d = 2R, we have d = max distance? Not necessarily: Could there be another pair with distance > d? If there is a pair with distance > d, then that pair would not be covered by the circle because the circle's diameter is 2R = d, and the distance between those two points > d, then they cannot both be inside the circle (since distance between any two points inside a circle is at most the diameter). So impossible. Therefore, if the minimal circle is defined by a diameter pair, that pair's distance must be the maximum distance among all points. So the pair is a farthest pair. So we could restrict to checking only the farthest pairs (i.e., compute the maximum distance among pairs, then only check circles with that pair as diameter). But we need to also consider that maybe the farthest pair circle does not cover all points, so minimal circle must be a triple circle. In that case, we still need to check triples. But for efficiency, we can still check all pairs; it's not expensive.
Thus code as above.
Double-check numeric stability for circumcenter formula:
Given points A(x1,y1), B(x2,y2), C(x3,y3). D = 2*(x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2)). This is twice the signed area (cross product (B-A) x (C-A)). So if |D| small, points are almost collinear; we skip.
Then:
Ux = ( (x1^2+y1^2)(y2-y3) + (x2^2+y2^2)(y3-y1) + (x3^2+y3^2)(y1-y2) ) / D
Uy = ( (x1^2+y1^2)(x3-x2) + (x2^2+y2^2)(x1-x3) + (x3^2+y3^2)(x2-x1) ) / D
Yes.
Alternatively, we could solve using linear algebra, but this is fine.
Potential sign errors: For Uy, some references use (x1^2+y1^2)(x3 - x2) + ... as above. But there is also formula: Uy = ( (x1^2+y1^2)(x3 - x2) + (x2^2+y2^2)(x1 - x3) + (x3^2+y3^2)(x2 - x1) ) / D. That's what we have. Good.
Let's test with a right triangle: (0,0), (2,0), (0,2). Compute: D = 2*(0*(0-2) + 2*(2-0) + 0*(0-0))? Actually x1=0,y1=0; x2=2,y2=0; x3=0,y3=2. Compute: x1*(y2-y3)=0*(0-2)=0; x2*(y3-y1)=2*(2-0)=4; x3*(y1-y2)=0*(0-0)=0; sum=4; D=8. Correct. xi2yi2: 0; xj2yj2:4; xk2yk2:4. Ux = (0*(0-2) + 4*(2-0) + 4*(0-0))/8 = (0+8+0)/8=1. Uy = (0*(0-2)?? Wait: (x1^2+y1^2)(x3 - x2) = 0(0-2)=0; + (x2^2+y2^2)(x1 - x3)=4(0-0)=0; + (x3^2+y3^2)(x2 - x1)=4(2-0)=8; )/8 = 1. So center (1,1). radius^2 = (0-1)^2+(0-1)^2=2, radius=√2≈1.414, which matches half of hypotenuse? Hypotenuse between (2,0) and (0,2) distance √8=2.828, half=1.414, yes.
So formula correct.
Now implement in Python.
But we have to be careful about using Python's float division. Since input coordinates are integers up to 1000, D will be integer multiple of 2? Actually cross product is integer, so D is integer (even). But we convert to float anyway.
Potential improvement: To avoid checking circles that are obviously larger than current best, we can compute radius_sq and if it's already >= best^2, skip the coverage check. That could prune many. But not necessary.
Also note that when we compute best, we could store best_sq and compare. But we need to output radius, so we can keep best as radius.
Implementation details:
Import sys, math.
Read lines.
Use list of tuples.
Edge Cases: N=50, many points.
Now test with the examples.
Example 1:
N=2, points (0,0),(1,0). pairs: for i=0,j=1: dx=1, dy=0, radius_sq=1/4=0.25, cx=0.5,cy=0. Check all points: For (0,0): dist_sq=(0-0.5)^2+0=0.25 <= 0.25 => ok. (1,0): same. So best= sqrt(0.25)=0.5. No triples. Print 0.5 with 15 decimals.
Example 2:
Compute pairs: (0,0)-(0,1): dx=0,dy=1 => radius_sq=0.25, cx=0,cy=0.5. Check (1,0): dist_sq=1^2+0.5^2=1.25 >0.25 => fails. (0,0)-(1,0): radius_sq=0.25, cx=0.5,cy=0, check (0,1): dist_sq=0.5^2+1^2=1.25>0.25 fails. (0,1)-(1,0): dx=1,dy=-1 => squared distance=2, radius_sq=0.5, cx=0.5,cy=0.5. Check (0,0): dist_sq=0.5^2+0.5^2=0.5 <=0.5? Actually 0.5^2+0.5^2=0.5, radius_sq=0.5, so okay. So best= sqrt(0.5)=~0.70710678. Triples: All three points: D = 2*(0*(0-0)?? Actually (0,0),(0,1),(1,0): compute D=2*(0*(1-0)+0*(0-0)+1*(0-1))? Let's compute: x1=0,y1=0; x2=0,y2=1; x3=1,y3=0. Then x1*(y2-y3)=0*(1-0)=0; x2*(y3-y1)=0*(0-0)=0; x3*(y1-y2)=1*(0-1)=-1; sum=-1; D=-2. Actually D = 2*(-1) = -2, abs>0. Ux = (0*(1-0) + (0^2+1^2=1)(0-0) + (1^2+0^2=1)(0-1)) / (-2) = (0+0+1*(-1))/(-2) = (-1)/(-2)=0.5. Uy = (0*(1-0?) Actually formula: Uy = (0*(x3-x2) + 1*(x1-x3) + 1*(x2-x1)) / D = (0*(1-0)=0? Actually (x3-x2) = (1-0)=1; (x1-x3)= (0-1)=-1; (x2-x1)= (0-0)=0 ) => 01 + 1(-1) + 1*0 = -1, divided by D=-2 => 0.5. So center (0.5,0.5), radius_sq = (0-0.5)^2+(0-0.5)^2=0.5. So radius sqrt(0.5) same. So best remains.
Example 3: We'll trust.
Thus answer.
Now finalize.
But we need to consider if there is any case where the minimal circle is determined by two points but they are not the farthest pair? As argued no. But still we check all pairs.
Double-check correctness for case where the minimal circle is defined by two points that are not the farthest, but still covering all points because the farthest pair is not actually a pair? That can't happen; the farthest distance is a property of the set. If there is a pair with distance d_max, any covering circle must have radius >= d_max/2. If the circle from a pair with distance d (< d_max) has radius d/2, that radius is < d_max/2, so it cannot cover the farthest pair. Therefore it cannot be a covering circle. So only pairs with d = d_max can possibly be covering circles (if they also cover other points). So we could restrict to only farthest pairs. But checking all is fine.
Now we must ensure that the algorithm returns the minimal radius. Since we check all candidates, we will find the minimal. However, there is a subtlety: The minimal circle may be defined by a triple but the circle computed from that triple might be slightly larger than the true minimal due to floating error? But we use double; it's fine.
Edge Cases: Points with identical coordinates? The problem says all points are different, so no duplicates.
Now output format: print with high precision. Use print("{:.15f}".format(best)). The examples show many digits (0.500000000000000000) 18 digits? But 15 is enough for 1e-6 error. Use 15 or 20. Python's default with repr might give many digits but we can just use .15f. The example shows 18 digits after decimal? Actually first example: "0.500000000000000000" that's 18 zeros after decimal? Let's count: after decimal: 500... that's 18 digits? Actually "0.500000000000000000" has 18 zeros after the 5? The 5 is after decimal then 18 zeros? Actually "0." then "5" then 17 zeros? Let's see: "0.500000000000000000" has 1 digit '5' and 17 zeros? I'll not worry. Using 15 decimal places is safe for error 1e-6. But we might as well use .10f? Safer to output with many digits. We can use print("{:.10f}".format(best))? But to be safe, use .15f. That yields 15 digits after decimal. The relative error requirement is 1e-6, so it's fine.
Alternatively, print using repr or just print(best) might output with scientific notation? Better to format.
Thus final solution.
Now verify algorithm with some random tests against known library? We could but not necessary.
Potential pitfalls: For large N, we have many triples, but the triple loop's innermost includes a loop over all points. This is O(N^4) worst-case (N=50 => ~ 2.5e6? Actually triples: about 19600, each inner loop N=50 => 980k, plus pairs: 1225*50=61k, total about 1.04M. That's fine.)
Now check if we need to consider circles defined by a single point? Not needed.
One more nuance: For the two-point case, we used the circle with diameter endpoints. But what if the minimal circle has two points on boundary but those two are not opposite ends? As argued, that can't be minimal because you could reduce radius by moving center to midpoint while keeping those two points inside? But would they remain on boundary? No, they would become inside. But then you could shrink radius until one of them hits boundary again. That would give a smaller radius. However, that new circle might not cover all points. But the minimal circle must be such that you cannot shrink it without uncovering some point. If the boundary has exactly two points A and B, then moving the center towards the midpoint reduces the distance to A and B, so you could reduce the radius while still having A and B inside, but you must ensure other points remain covered. However, if the boundary has exactly two points, they are exactly at distance R. If you move the center towards the midpoint, the distance to A and B decreases, so they become inside. Then you can reduce R until either A or B becomes boundary again or some other point becomes boundary. This suggests that if the circle is minimal and only A and B are on the boundary, then any movement of center that reduces R would cause some point to become outside. But is it possible that the minimal circle with exactly two boundary points does not have center at midpoint? Consider the earlier example with three points A, B, C forming an acute triangle. The minimal circle is the circumcircle with all three on boundary. That's three boundary points. For obtuse triangle, minimal circle is the diameter circle, center at midpoint. So indeed two boundary points implies midpoint.
But there is a scenario with more than three points where the minimal circle might have exactly two boundary points, but the center might be forced away from the midpoint because of other points? Let's try to construct: Suppose we have points A, B, and many other points that lie inside the circle defined by the diameter AB? Then the minimal circle is the diameter AB, center at midpoint. If there is a point that lies outside the diameter circle but inside some other circle that has A and B on boundary with a larger radius? Then the minimal circle would be a circle with A, B, and that point on boundary (three points) or some other configuration. So not two points.
What about four points: A, B, C such that C is outside the AB diameter circle, and D is somewhere else. The minimal circle likely has three points (maybe A, B, C or others). So again, two-point case only when the farthest pair circle covers all, i.e., the set is within the lens shape? Actually more precisely, when the smallest enclosing circle is determined by two points, those two must be a diametral pair, and all other points must lie in the intersection of the two disks of radius R centered at each? Anyway, classic result holds.
Thus we are safe.
Now potential issues: For the triple case, when the triangle is obtuse, the circumcenter will be outside, but the circle still exists. However, the circumcircle radius will be larger than the half of the longest side. But we still check it. But we must ensure that we don't inadvertently accept a circumcircle that is not actually covering all points? It will cover the three points, but may not cover others? But if it doesn't cover others, it will be rejected during the all-points check. So fine.
One more nuance: If the three points are nearly collinear, the circumcenter can be far away and radius very large. But we skip if collinear (|D| small). However, if they are nearly collinear but not exactly, the circumcenter may be far, but the radius might be huge. That's okay; it will likely not be the minimal. But we must handle numeric overflow? For points up to 1000, the circumcenter coordinates could be large if points are almost collinear. For example, points (0,0), (1,0), (2,1e-6)? The circumcenter might have large coordinates. But still within double range. So okay.
Thus code is fine.
We should also consider that for N=50, checking all triples may be a bit slow in Python if we have many operations. But 1M distance checks each with a few multiplications and additions is fine (likely <0.1 sec). However, we also have the overhead of loops and function calls. Python loops can be slower, but 2e4 triples * 50 = 1e6 inner checks, each with arithmetic; it should run within time limit (typical AtCoder time limit maybe 2 sec). Let's estimate: 1e6 operations might take around 0.02-0.05 sec? Actually Python can do about 50 million simple operations per second? No, it's slower. A million operations might be around 0.05-0.1 sec. But loops overhead may be more. However, 20k triples, each inner loop of 50 points, that's 1e6 point checks. Each point check involves subtraction, multiplication, addition, comparison. That's maybe 10 operations. So maybe 10 million operations, which is okay. But the triple loops also have overhead of the outer loops. 20k triples is not huge. So it should be fine.
But there is a nuance: we also check pairs, which is small.
Thus finalize.
Now we may also need to consider that the minimal circle might be defined by a single point? Not for N>=2.
Now we produce final answer.
But we should also consider if there is any case where we might miss the optimal circle because the circle defined by three points does not necessarily have those three points on the boundary of the minimal circle? Wait: If the minimal circle has three boundary points, then those three are on the boundary. So we will find it when we check that triple. But it's possible that the minimal circle has more than three boundary points. In that case, any three of those boundary points (non-collinear) will define the same circle (the minimal circle). So our triple check will include some triple that yields that circle. However, careful: If the points on the boundary are more than three but some subset of three might not uniquely define that circle? Actually, for a given circle, any three non-collinear points on that circle uniquely determine the circle (since three points determine a circle unless collinear). So any triple of boundary points (non-collinear) will produce the same circle. So we will find it.
Thus algorithm is correct.
Implementation details:
Use math.hypot? Not needed.
Use for loops with indices.
We'll write:
import sys, math
def main():
input = sys.stdin.readline
N = int(input())
pts = [tuple(map(int, input().split())) for _ in range(N)]
best = float('inf')
eps = 1e-9
code
# Pre-store coordinates in separate lists for speed? Might be beneficial.
xs = [p[0] for p in pts]
ys = [p[1] for p in pts]
# Pairs
for i in range(N):
xi, yi = xs[i], ys[i]
for j in range(i+1, N):
xj, yj = xs[j], ys[j]
cx = (xi + xj) * 0.5
cy = (yi + yj) * 0.5
dx = xi - xj
dy = yi - yj
r_sq = (dx*dx + dy*dy) * 0.25
# if r_sq already >= best^2, maybe skip? But best initially inf.
# Check all points
ok = True
for k in range(N):
dxk = xs[k] - cx
dyk = ys[k] - cy
if dxk*dxk + dyk*dyk > r_sq + eps:
ok = False
break
if ok:
r = math.sqrt(r_sq)
if r < best:
best = r
# Triples
for i in range(N):
xi, yi = xs[i], ys[i]
for j in range(i+1, N):
xj, yj = xs[j], ys[j]
for k in range(j+1, N):
xk, yk = xs[k], ys[k]
# Check collinearity
D = 2.0 * (xi*(yj - yk) + xj*(yk - yi) + xk*(yi - yj))
if abs(D) < 1e-12:
continue
# Compute circumcenter
xi2yi2 = xi*xi + yi*yi
xj2yj2 = xj*xj + yj*yj
xk2yk2 = xk*xk + yk*yk
Ux = (xi2yi2*(yj - yk) + xj2yj2*(yk - yi) + xk2yk2*(yi - yj)) / D
Uy = (xi2yi2*(xk - xj) + xj2yj2*(xi - xk) + xk2yk2*(xj - xi)) / D
dx = xi - Ux
dy = yi - Uy
r_sq = dx*dx + dy*dy
# If r_sq already >= best^2, skip check? Might prune.
if r_sq >= best*best:
continue
# Check all points
ok = True
for m in range(N):
dxm = xs[m] - Ux
dym = ys[m] - Uy
if dxm*dxm + dym*dym > r_sq + eps:
ok = False
break
if ok:
r = math.sqrt(r_sq)
if r < best:
best = r
print("{:.15f}".format(best))
if name == "main":
main()
But note: In the pair check, we might also skip if r_sq >= best^2. However best initial inf, so fine. But after some circles found, we can prune. We'll add that: compute if r_sq >= best*best: continue before checking all points.
However, careful: Because of epsilon, maybe a circle with radius slightly larger than current best might be considered but we skip anyway, that's fine as we only need the minimum.
Now check for correctness: For pairs, we compute r_sq and if r_sq >= best*best, we can skip checking. This can speed up.
But we must compute best^2 (bestbest) each time; we can keep best_sq = bestbest as variable and update.
Simplify: Use best_sq variable.
Initialize best = float('inf'), best_sq = float('inf').
When we find a valid circle with radius r, update if r < best: best = r; best_sq = r*r.
In checks: if r_sq >= best_sq: continue (skip).
Now pair check: compute r_sq, if r_sq >= best_sq: continue.
But caution: For pairs, the circle is defined by the pair, and its radius is half the distance. If we skip because r_sq >= best_sq, we might miss a circle that is exactly the same radius? But if r_sq == best_sq, that circle would not improve best; it's okay to skip. So we can continue.
For triples: similar.
Now epsilon: For comparing squared distances, we add eps to r_sq threshold. However, for pruning based on r_sq, we should use exact r_sq without eps, because we want to skip circles that are not better than current best. Even if r_sq is slightly larger than best_sq, it's not better. So fine.
Now for the check of all points, we need to use eps to account for floating errors. We'll use a small absolute epsilon. Since coordinates up to 1000, squared distances up to ~2e6, a tolerance of 1e-7 might be too small? Actually if there is rounding error of about 1e-12 in coordinates, squared error might be around 1e-9? We'll use 1e-9.
Better to use a relative epsilon? But absolute should be fine. To be safe, we can use 1e-9.
Alternatively, we can avoid epsilon by using <= in comparisons without epsilon, but due to floating errors, we might reject a valid circle because a point that should be exactly on boundary is computed as slightly outside. For example, for the pair circle, we compute cx = (xi+xj)/2. For the defining points, the computed squared distance from cx to xi may be exactly (dx/2)^2? Let's see: (xi - cx) = (xi - (xi+xj)/2) = (xi - xj)/2. Similarly, y difference. So squared distance = ((xi-xj)^2 + (yi-yj)^2)/4 = r_sq exactly. In floating point, if xi, xj are integers, (xi+xj)/2 may be .5, which is exactly representable in binary? Not always. For example, 1 and 2 => 1.5 exactly in binary? 1.5 is 3/2, which in binary is 1.1, exactly representable. Actually any number that is a multiple of 0.5 is representable? In IEEE double, numbers with denominator power of two are representable exactly. Since (xi+xj) is integer, divided by 2 yields either integer or half-integer, which are exactly representable. So cx, cy are exact. Then (xi - cx) is either integer/2, also exact. So r_sq computed as sum of squares of those halves. Since both are fractions with denominator 2, their squares have denominator 4, which are also representable exactly? Not necessarily exactly if numerator not divisible by 4? Actually, floating point binary representation can represent numbers like 0.25, 0.5, 0.75, etc., exactly if denominator is power of two. But (dx^2+dy^2)/4: dx and dy are integers, so dx^2+dy^2 is integer; dividing by 4 yields a number that is either integer, .25, .5, .75? Actually integer/4 yields a multiple of 0.25, which is representable exactly in binary (since 0.25=2^{-2}). So yes, r_sq is exact. And the squared distance from cx to another point computed as (x - cx)^2 + (y - cy)^2, where x, y are integers, cx, cy are half-integers. The differences are half-integers, squares are multiples of 0.25, sum is multiple of 0.25, so exact. So for pair circles, there should be no floating error; all distances are exactly representable. So we could skip epsilon for pair circles. But for circumcenter, errors occur. So it's safe to keep epsilon.
To be thorough, we can use a small epsilon.
Now potential issue: When computing circumcenter, D may be large (up to about 210001000? Actually cross product magnitude can be up to ~ (1000*1000) = 1e6, so D up to 2e6, fine). Ux, Uy computed via division may have rounding errors.
Thus algorithm is fine.
Now about the time: It should be okay.
But wait, for N=50, triple loops: 50 choose 3 = 19600. That's fine. However, we also do inside a loop over N points (50) for each triple, so 980k checks. That's okay.
But we can further optimize: Precompute all points coordinates in lists, as done.
Also, note that many triples will be skipped early if r_sq >= best_sq, so after some good candidate found, many later circles will be skipped. In many cases, the minimal circle might be relatively small early? Not guaranteed. But we can include pruning.
Now test on worst-case: all points on a large circle. The minimal circle is that circle. Our algorithm will check many triples, but the best may be found early? Possibly not, but we must check all triples anyway. However, we can add a heuristic: sort points? Not needed.
Complexities are fine.
Edge Cases: N=2, triples loop doesn't execute.
Now we should ensure we handle the case where the best is never updated. That should not happen. But we can initialize best to a large number; at least one candidate will be found.
Now finalize code.
But the problem statement says "Print the minimum radius". So we output radius.
We can also use simpler approach: Use the Welzl algorithm which is O(N) expected, but implementing recursion with backtracking might be simpler? However, brute force is simpler.
Thus I'll proceed.
Now about output precision: Use something like print("{:.10f}".format(best))? The examples show many digits, but the error tolerance is 1e-6, so 10 decimal places is fine. But to be safe, we can print with 15 decimal places.
Thus final answer.
But I recall that sometimes the minimal circle can be defined by a single point if N=1, but N>=2.
Now produce final code.
Double-check circumcenter formula signs: Many sources have Uy = ( (x1^2+y1^2)(x2 - x3) + (x2^2+y2^2)(x3 - x1) + (x3^2+y3^2)(x1 - x2) ) / D with a different sign. Actually we used (x3 - x2) for first term, (x1 - x3) for second, (x2 - x1) for third. Let's verify with a known example: Right triangle (0,0),(2,0),(0,2). We got center (1,1). Let's compute using alternative: (x1^2+y1^2)(x2 - x3) = 0*(0-2)=0; (x2^2+y2^2)(x3 - x1) = 4(2-0)=8; (x3^2+y3^2)(x1 - x2) = 4(0-0)=0; sum =8, D=8? D=8? Actually we computed D=8? D = 2*(0*(0-2) + 2*(2-0) + 0*(0-0)) = 2*(0+4+0)=8. So Uy = 8/8 =1. So that alternative gives (1,1) as well. So both forms produce same. Ours used (xk - xj), (xi - xk), (xj - xi). That's the negative of (x2 - x3) etc? Let's see: For i=0,j=1,k=2: (xk - xj) = (x2 - x1), (xi - xk) = (x0 - x2), (xj - xi) = (x1 - x0). While the alternative uses (x2 - x3)?? Actually indices may differ. But since we are consistent with the formula from known references, it's fine.
I'll use the formula from Wikipedia: For points A, B, C:
Ux = ((A^2)(By - Cy) + (B^2)(Cy - Ay) + (C^2)(Ay - By)) / D
Uy = ((A^2)(Cx - Bx) + (B^2)(Ax - Cx) + (C^2)(Bx - Ax)) / D
where A^2 = Ax^2+Ay^2 etc. D = 2*(Ax*(By - Cy) + Bx*(Cy - Ay) + Cx*(Ay - By)). This matches our code if we set i=A, j=B, k=C. Then Uy = ( (A^2)(Cx - Bx) + (B^2)(Ax - Cx) + (C^2)(Bx - Ax) ) / D. Yes, we have (xi2yi2)(xk - xj) + (xj2yj2)(xi - xk) + (xk2yk2)(xj - xi). That's exactly (A^2)(Cx - Bx) + (B^2)(Ax - Cx) + (C^2)*(Bx - Ax). Good.
Thus correct.
Now implement.
Potential bug: In the pair check, we used r_sq = (dxdx + dydy) * 0.25. Since dx and dy are ints, multiplication and division by 4 is exact if we do /4.0. But using *0.25 is also exact because 0.25 is power of two. So fine.
Now finalize.
One more thing: When we compute best_sq, we update after we compute r. But for pruning we need best_sq before we have found any circle. We'll keep best_sq = inf.
I'll add a check: if best_sq is inf, then we cannot prune based on r_sq >= best_sq because that would skip all. So we can implement if r_sq >= best_sq: continue, but when best_sq is inf, condition false because r_sq < inf. So fine.
Now code.
But careful: In triple loop, after computing r_sq, we compare if r_sq >= best_sq: continue. This will skip many if best is already small.
Now note: best is updated only after full check, but we might have a candidate with r_sq less than current best_sq. That's good.
Now test with example 3 quickly by mental? Not needed.
Now final code.
But there is also possibility that the minimal circle is defined by three points but the circumcenter computed via formula might have large floating error if D is small. But we skip small D.
Now code is ready.
One more thought: Could the minimal circle be determined by a pair but the pair is not a farthest pair because the farthest pair includes a point that is not on the boundary? Wait, if the minimal circle is defined by two points, they are on the boundary, and the circle's diameter is 2R. Since the distance between those two points is exactly 2R? No, they are opposite ends of a diameter, so distance = 2R. So the distance between them is exactly the diameter. Any other two points have distance <= diameter (since they lie inside the circle). So that pair's distance is the maximum distance. So indeed the pair is a farthest pair.
Thus we could compute the farthest distance first and only consider those pairs, but not necessary.
Now regarding the double loops: we might want to break out early if best is 0? Not possible.
Now final answer.
But I recall that there is also a possibility that the minimal circle is determined by one point if all points are the same, but distinct points prevents that.
Thus solution is correct.
Now we will produce final answer.
Before final, let's test with a custom case: N=3 points: (0,0), (10,0), (5,10). Compute manually: The triangle? Let's compute circumcircle. Using our algorithm, should get some radius.
But trust.
Now think about potential overflow: In Python, ints are arbitrary precision, but we convert to float for calculations. So fine.
Now finalize.
But to be thorough, we could also add an early break: if we find a circle with radius 0? Not possible.
Now final code.
One more thing: In the triple loop, after computing Ux, Uy, we computed r_sq using dx, dy from xi, yi to U. But we should ensure that r_sq is non-negative. It will be.
Now we also might want to consider circles defined by two points with center at midpoint but radius might be larger than needed? No.
Now final.
But wait: There is a known alternative: use min enclosing circle via randomized algorithm (Welzl). However, the brute force is simpler.
Now I'll produce the final answer in the required format.
Now note: The input may contain extra spaces; we use split.
All good.
Let's finalize. ```python
import sys
import math
def solve() -> None:
input = sys.stdin.readline
N = int(input())
pts = [tuple(map(int, input().split())) for _ in range(N)]
xs = [p[0] for p in pts]
ys = [p[1] for p in pts]
code
INF = float('inf')
best = INF
best_sq = INF
eps = 1e-9
# ----- circles determined by two points (diameter) -----
for i in range(N):
xi, yi = xs[i], ys[i]
for j in range(i+1, N):
xj, yj = xs[j], ys[j]
cx = (xi + xj) * 0.5
cy = (yi + yj) * 0.5
dx = xi - xj
dy = yi - yj
r_sq = (dx*dx + dy*dy) * 0.25
if r_sq >= best_sq:
continue
ok = True
for k in range(N):
dxk = xs[k] - cx
dyk = ys[k] - cy
if dxk*dxk + dyk*dyk > r_sq + eps:
ok = False
break
if ok:
r = math.sqrt(r_sq)
best = r
best_sq = r * r
# ----- circles determined by three points (circumcircle) -----
for i in range(N):
xi, yi = xs[i], ys[i]
for j in range(i+1, N):
xj, yj = xs[j], ys[j]
for k in range(j+1, N):
xk, yk = xs[k], ys[k]
# Check collinearity (D = 2 * signed area)
D = 2.0 * (xi*(yj - yk) + xj*(yk - yi) + xk*(yi - yj))
if abs(D) < 1e-12:
continue
xi2 = xi*xi + yi*yi
xj2 = xj*xj + yj*yj
xk2 = xk*xk + yk*yk
Ux = (xi2*(yj - yk) + xj2*(yk - yi) + xk2*(yi - yj)) / D
Uy = (xi2*(xk - xj) + xj2*(xi - xk) + xk2*(xj - xi)) / D
dx = xi - Ux
dy = yi - Uy
r_sq = dx*dx + dy*dy
if r_sq >= best_sq:
continue
ok = True
for m in range(N):
dxm = xs[m] - Ux
dym = ys[m] - Uy
if dxm*dxm + dym*dym > r_sq + eps:
ok = False
break
if ok:
r = math.sqrt(r_sq)
best = r
best_sq = r * r
# Output with sufficient precision
print("{:.15f}".format(best))