Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Written by RR
- {$MODE OBJFPC}
- uses math;
- const
- FINP = '';
- FOUT = '';
- MAXN = 100111;
- eps = 1e-9;
- type
- point = record x,y:double; end;
- circle = record x,y,r:double; end;
- var
- f1,f2 : text;
- test,n : longint;
- a : array[1..MAXN] of point;
- res : circle;
- procedure openF;
- begin
- assign(f1,FINP); reset(f1);
- assign(f2,FOUT); rewrite(f2);
- end;
- procedure closeF;
- begin
- close(f1);
- close(f2);
- end;
- procedure inp;
- var
- i:longint;
- begin
- read(f1,n);
- for i:=1 to n do
- with a[i] do
- read(f1,x,y);
- end;
- procedure update2(a,b:point);
- begin
- res.x:=(a.x+b.x)/2;
- res.y:=(a.y+b.y)/2;
- res.r:=sqr(a.x-res.x) + sqr(a.y-res.y);
- end;
- procedure update3(a,b,c:point);
- var
- s,u,v:double;
- begin
- u:=(c.y-b.y)/2-(c.x-b.x)*(a.x-b.x)/2/(b.y-a.y);
- v:=(c.y-a.y)*(a.x-b.x)/(b.y-a.y)-(a.x-c.x);
- s:=u/v;
- res.x:=(a.x+c.x)/2+s*(c.y-a.y);
- res.y:=(a.y+c.y)/2+s*(a.x-c.x);
- res.r:=sqr(a.x-res.x)+sqr(a.y-res.y);
- end;
- function isInside(a:point):boolean;
- begin
- exit( sqr(a.x-res.x) + sqr(a.y-res.y) < res.r+eps );
- end;
- procedure solve;
- var
- i,j,k:longint;
- begin
- update2(a[1],a[2]);
- for i:=3 to n do
- if not isInside(a[i]) then
- begin
- update2(a[1],a[i]);
- for j:=1 to i-1 do
- if not isInside(a[j]) then
- begin
- update2(a[i],a[j]);
- for k:=1 to j-1 do
- if not isInside(a[k]) then
- update3(a[i],a[j],a[k]);
- end;
- end;
- writeln(f2,sqrt(res.r):0:2);
- writeln(f2,res.x:0:2,' ',res.y:0:2);
- end;
- begin
- openF;
- read(f1,test);
- for test:=1 to test do
- begin
- inp;
- solve;
- end;
- closeF;
- end.
Advertisement
Add Comment
Please, Sign In to add comment