BZOJ1337: Minimum Circle cover

Source: Internet
Author: User

Title: Ask for the minimum circle coverage of n points.

Puzzle: Minimum circle overlay, upper template. Proof of complexity can be stamped: here

Code:

1#include <cstdio>2#include <cstdlib>3#include <cmath>4#include <cstring>5#include <algorithm>6#include <iostream>7#include <vector>8#include <map>9#include <Set>Ten#include <queue> One#include <string> A #defineINF 1000000000 - #defineMAXN 1000000+5 - #defineMAXM 200000+5 the #defineEPS 1e-6 - #definell Long Long - #defineull unsigned long Long - #definePA pair<int,int> + #defineFor0 (i,n) for (int i=0;i<= (n); i++) - #defineFor1 (i,n) for (int i=1;i<= (n); i++) + #defineFor2 (i,x,y) for (int i= (x); i<= (y); i++) A #defineFor3 (i,x,y) for (int i= (x); i>= (y); i--) at #defineFor4 (i,x) for (int i=head[x],y=e[i].go;i;i=e[i].next,y=e[i].go) - #defineFor5 (N,M) for (int. i=1;i<=n;i++) for (int j=1;j<=m;j++) - #defineMoD 1000000007 - #defineLCH K<<1,l,mid - #defineRCH K<<1|1,mid+1,r - #defineSQR (x) (x) * (x) in #defineDB Double - using namespacestd; toInlineintRead () + { -     intx=0, f=1;CharCh=GetChar (); the      while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();} *      while(ch>='0'&&ch<='9') {x=Ten*x+ch-'0'; ch=GetChar ();} $     returnx*F;Panax Notoginseng } - struct Point the { + db x, y; APointoperator+ (point B) {return(point) {x+b.x,y+b.y};} thePointoperator/(db b) {return(point) {x/b,y/b};} + }A[MAXN]; - intN; $ db ans; $Inline DB Dist (point A,point b) {returnsqrt (SQR (a.x-b.x) +SQR (a.y-b.y));} - Inline Point Calc (db a,db b,db c,db d,db e,db f) - { the   return(point) {(c*e-f*b)/(A*e-d*b), (a*f-c*d)/(a*e-d*b)}; - }WuyiInline pointGet(Point a,point b,point c) the { -    returnCalc (b.x-a.x,b.y-a.y, (Sqr (b.x) +sqr (B.Y)-sqr (a.x)-SQR (A.Y))/2.0, WuC.x-b.x,c.y-b.y, (Sqr (c.x) +sqr (C.Y)-sqr (b.x)-SQR (B.Y))/2.0); - } About intMain () $ { -Freopen ("Input.txt","R", stdin); -Freopen ("output.txt","W", stdout); -n=read (); AFor1 (i,n) scanf ("%LF%LF",&a[i].x,&a[i].y); +For1 (i,n) Swap (A[rand ()%n+1],a[rand ()%n+1]); theans=0; -For1 (I,n)if(Dist (a[i],a[0]) >ans+EPS) $    { thea[0]=a[i];ans=0; theFor1 (j,i-1)if(Dist (a[j],a[0]) >ans+EPS) the         { thea[0]= (A[i]+a[j])/2; Ans=dist (a[0],a[i]); -For1 (k,j-1)if(Dist (a[k],a[0]) >ans+EPS) in             { thea[0]=Get(A[i],a[j],a[k]); Ans=dist (a[0],a[i]); the             } About         } the    } theprintf"%.2f%.2f%.2f\n", a[0].x,a[0].y,ans); the    return 0; +}
View Code

I'm not going to tell you this is three times times the experience.

BZOJ1337: Minimum Circle cover

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.